[Evaluate] optimize listview controls filling in TVSetup - Channel list for groups (1 Viewer)

mm1352000

Development Group
  • Team MediaPortal
  • September 1, 2008
    21,571
    8,218
    New Zealand New Zealand
    Country flag
    Hi again Vasilich

    Last thing before I go to bed. :)
    1. Yes the binaries were built on latest SVN.
    2. Patches attached.

    mm
     

    Attachments

    Vasilich

    Test Group
  • Team MediaPortal
  • August 30, 2009
    3,393
    1,170
    Germany, Mayence
    Russian Federation Russian Federation
    Country flag
    • Thread starter
    • Moderator
    • #12
    thanks mm, i have tested all versions of SetupTV and wrote down time it took for populating of All Channels TV group:
    1. original unpatched: 80 seconds
    2. with listview fill optimization: 37 seconds
    3. with listview fill optimization and removed second SQL query: 26 seconds
    4. with dictionary: 14 seconds.
    So i think it is clear where we should tend. I will try to further optimize dictionary patch (there are some points to try ;) ) and post the results later.
     

    mm1352000

    Development Group
  • Team MediaPortal
  • September 1, 2008
    21,571
    8,218
    New Zealand New Zealand
    Country flag
    Excellent :)
    I'll leave that in your capable hands. Obviously whatever we do should be applied to the full channel lists as well as the groups, and both the TV and radio code will need updating. If you're quick then it *might* be possible to get this in 1.2.0rc (no promises).

    mm
     

    gibman

    Retired Team Member
  • Premium Supporter
  • October 4, 2006
    2,998
    1,372
    Aarhus
    Denmark Denmark
    Country flag
    this is potentially an expensive call:

    Code:
     try
    +          {
    +            tuningDetails = d[channel.IdChannel];
    +          }
    +          catch (KeyNotFoundException)
    +          {
    +            tuningDetails = new List<TuningDetail>();
    +          }
    use .TryGetValue whenever possible for performance.

    Code:
    IList<TuningDetail> tuningDetails;
    if (!d.TryGetValue(channel.IdChannel, out tuningDetails) )
    {
       tuningDetails = new List<TuningDetail>();
    }
    /gibman
     

    mm1352000

    Development Group
  • Team MediaPortal
  • September 1, 2008
    21,571
    8,218
    New Zealand New Zealand
    Country flag
    Thanks gibman :D
    My C# inexperience showing... I would have thought they used some kind of fast-to-evaluate hashing function for key -> value lookup.
     

    gibman

    Retired Team Member
  • Premium Supporter
  • October 4, 2006
    2,998
    1,372
    Aarhus
    Denmark Denmark
    Country flag
    no problem..

    u can even do something like:

    Code:
    IList<TuningDetail> tuningDetails;
    bool hasTuningDetails = d.TryGetValue(channel.IdChannel, out tuningDetails);
    if (hasTuningDetails)
    {
       foreach (TuningDetail detail in tuningDetails)
              {
                if (detail.FreeToAir)
                {
                  hasFta = true;
                }
                if (!detail.FreeToAir)
                {
                  hasScrambled = true;
                }
              }
    }
    
    ...
    
    if (hasTuningDetails && tuningDetails.Count > 0)
    {
      item.SubItems.Add(tuningDetails[0].ChannelNumber.ToString());
    }
    this way we avoid the "tuningDetails = new List<TuningDetail>();"

    try catch in a loop is often costly, but only if it runs into the catch part ... try is for "free" though :)

    /gibman
     

    Vasilich

    Test Group
  • Team MediaPortal
  • August 30, 2009
    3,393
    1,170
    Germany, Mayence
    Russian Federation Russian Federation
    Country flag
    • Thread starter
    • Moderator
    • #17
    thanks Gibman,
    use TryGetValue was my first idea, as KeyNotFoundException is known for its expense.

    Other question not directly connected ti the topic - what this code
    Code:
        if (detail.FreeToAir)
            {
              hasFta = true;
            }
            if (!detail.FreeToAir)
            {
              hasScrambled = true;
            }
          }
    
          int imageIndex;
          if ([B][COLOR="Red"]hasFta && hasScrambled[/COLOR][/B])
          {
            imageIndex = 5;
          }
          else if (hasScrambled)
          {
            imageIndex = 4;
          }
          else
          {
            imageIndex = 3;
          }
    suppose to do? can selected condition ever be true?
    are the channels with both FTA and Scrambled flags set exist? we have in DB only one flag FreeToAir.
     

    mm1352000

    Development Group
  • Team MediaPortal
  • September 1, 2008
    21,571
    8,218
    New Zealand New Zealand
    Country flag
    It can be the case if a channel has one or more tuning details that are FTA and one or more that are encrypted... ;)
     

    Vasilich

    Test Group
  • Team MediaPortal
  • August 30, 2009
    3,393
    1,170
    Germany, Mayence
    Russian Federation Russian Federation
    Country flag
    • Thread starter
    • Moderator
    • #19
    just for me to get it clear: every channel can have several TuningDetails? how this supposed to work? where the information about different tuningdetails for same channel comes from? I thought when scanning every detected channel gets its own ID... or is it all about combining channels from different tuners into one?
     

    mm1352000

    Development Group
  • Team MediaPortal
  • September 1, 2008
    21,571
    8,218
    New Zealand New Zealand
    Country flag
    You get multiple tuning details if you combine channels. This will only be relevant for some channels and for some people. I choose not to use the feature because you can't prioritise the HD sources for viewing or recording, however some people do it because it gives more scheduling flexibility. There is more chance to resolve a scheduling conflict on a channel if TV Server knows you have multiple sources for a channel...
     

    Users Who Are Viewing This Thread (Users: 0, Guests: 1)

    OP Similar threads Forum Replies Date
    splatterpop My optimized dvb epg configuration for tv server MediaPortal 1 Talk 0
    henrysinn Remote - W10 Gyro by Pepper Jobs General 8
    G Remote control suggestions? MediaPortal 1 Talk 16
    mrmojo666 [Tv Server Plugin ]Direct Show Video Control Plugin 0.0.0.1 for Hauppauge PVR cards MediaPortal 1 Plugins 0
    T TV Player Controls WMC Skin 0
    emphatic Allow remote control mapping of all plugins Improvement Suggestions 0
    S Problem with Remote Control One-for-all Streamer Newcomers Forum 6
    Rob Hexenmeister Playing with hyperlinkParameter and List Control indexes General Support 2
    mrmojo666 [Plugin]Marantz Control Plugin 0.0.0.2 MediaPortal 1 Plugins 2
    T Can Emprex 3009ARF III MCE Remote Control be used to toggle Fullscreen/Windowed mode?? Remotes 7
    N [Proposal] Make text input using remote control easier MediaPortal 2 4
    Rob Hexenmeister Current control ID General Support 10
    N [Proposal] Make text input possible with remote control in SMS style MediaPortal 2 1
    N [Finished] [MP2-789] MCE remote control Recorded TV and My Pictures buttons do not work MediaPortal 2 17
    Rob Hexenmeister [solved] Latests Media Handler - Skinning an updating window or control Fanart Handler 26
    N How to input text with the remote control General 3
    milagroso Remote control with EventGhost - I'm stuck, need help General 3
    C Manual Control doesn't work anymore inside TVServer General Support 4
    HTPCSourcer Harmony Smart Control freezes Input/Output Interfaces 3
    coolblue [solved] Double Volume Control with RC6 IR General 4
    F Blu-Ray Contextual Menu Remote Key/Keyboard Watch / Listen Media 5
    Top Bottom