×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

compare array, map, vector for speed

compare array, map, vector for speed

compare array, map, vector for speed

(OP)
Windows XP Pro, Visual Studio, C++, MFC, No ATL or CLR

We need to access an array of pointers using the following concept:

CODE

Int tag;  // 32 bit int
Struct{ int, int, bool } my_struct;
My_struct  *p_info;

  // the critical part is fetching the pointers.
p_info = my_array[ tag ]
Speed takes priority over space.  Tag is currently 16 bit integers and may grow to 19 bits.  Once the array is populated it never changes.  Populating the array is not time critical.  Lookup time is critical.  Tag values are not contiguous but tend to populate the lower values followed by the higher.

This is an application that runs in a telemetry system and receives the raw data from the remote sources.  There will be multiple streams of data at differing rates and up to 20 MHz each.  Data arrives in my application as single stream organized as pairs: tag, value.  The tag is used to identify the data.  The data is saved in various locations according to which stream it belongs to and its type of data. (Hence the structure pointers in the array.)  When sufficient data is received, the data is processed, reformatted some, and sent to a display device for real time monitoring.

Which is better:   standard array of pointers,   std::vector,  CArray, or  std::map.

So far, from what I have found,  I think map is the slowest requiring several lookups to fetch the data item.  I don't know about std::vector, but I do believe that the speed of a standard array is not likely to be beat.  But it does take more space.  I am tending toward the simple array because you just cannot get any simpler and faster.

Just in case, the system has dual CPUs with quad core (eight cores) and four Gig of memory.
 

We need to know what a dragon is
before we study its anatomy.
(Bryan Kelly, 2010)
 

RE: compare array, map, vector for speed

2^19 pointers in pre-allocated ~2MB array (for 32-bit arch) and 4GB memory system - what's a problem? Of course, it's the fastest access solution: direct access with minimal overheads.

See also Kyoto Cabinet NoSQL DB C++ library (extremelly fast and compact tool):
[url]http://fallabs.com/kyotocabinet/[/url]
for in-memory DB and timestamp-tag-value data management.
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close