Results 1 to 5 of 5

Thread: Is QMap efficient in case of frequent read access ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2006
    Posts
    55
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default Re: Is QMap efficient in case of frequent read access ?

    Hi
    As far as I can tell from few tests, if you look after performance of search,
    size matters :
    Under approximately 50 items, an array/vector of pairs is better
    Between 50 and 400 items, an ordered map (like QMap) works better
    Over 400, a hash map shows better performance.
    But if the usage is running through each item, array/vector of pairs
    will be the optimum.
    Hth.

  2. #2
    Join Date
    Jan 2006
    Posts
    162
    Qt products
    Qt3
    Platforms
    Windows
    Thanks
    9

    Default Re: Is QMap efficient in case of frequent read access ?

    How did you test performances ?

  3. #3
    Join Date
    May 2006
    Posts
    55
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default Re: Is QMap efficient in case of frequent read access ?

    Hi,
    I am a bit late with my answer.
    I don't have the code anymore, I guess. But this is what I remember :
    I tested by filling randomly generated longs in a container
    and in a vector for randomly selecting the ones to search for
    and repeated the search tests for some times and measured the times
    it had taken.
    Hth

  4. #4
    Join Date
    May 2006
    Posts
    55
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    7
    Thanked 1 Time in 1 Post

    Default Re: Is QMap efficient in case of frequent read access ?

    Ouch, I read your first post too quickly !
    It appears that the set of your key has no hole,
    as it grows from zero without a gap, and you use
    every entry of your virtual map.
    Here, obviously, anything more complicated than a "vector"
    (an array would suffice, as it is static data --the keys are known
    at compile time--) is overkill and
    brings its overhead in time and memory consumption.
    So my advice is : stick to an array.
    Hth

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.