473,326 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

searching for article...

I've been searching for a specific article for awhile now. About two
years ago (maybe longer) there was an article in the C/C++ User's
Journal that compared the performances of various stl containers.
Unfortunately, while I remember the topic, I don't remember much else,
so if anyone is inclined to help me find it, they'll have to do some
detective work. I remember it was co-written by two people, one of
which I *think* is Herb Sutter (but I may be way off-base on that).
I'm not positive if it was in the CUJ, either, as it could have been
Dr. Dobbs. I doubt it was in any other magazine, as I remember
reading it at work and at the time we only subscribed to those two.

Specific information about the article: it noted that while list was
better for insertion in the middle, it turns out that vector is almost
always fast enough. And by that I mean fast enough that the article
recommended just always using vector.

I'd like to reread this article, and it's driving me batty that I
can't just google "vector list comparison c++ article" and get
anything useful.

Nov 1 '07 #1
4 1574
mo*****@gmail.com wrote:
I've been searching for a specific article for awhile now. About two
years ago (maybe longer) there was an article in the C/C++ User's
Journal that compared the performances of various stl containers.
Unfortunately, while I remember the topic, I don't remember much else,
so if anyone is inclined to help me find it, they'll have to do some
detective work. I remember it was co-written by two people, one of
which I *think* is Herb Sutter (but I may be way off-base on that).
If you aren't, you will find the article here:
http://www.gotw.ca/publications/index.htm
I'm not positive if it was in the CUJ, either, as it could have been
Dr. Dobbs. I doubt it was in any other magazine, as I remember
reading it at work and at the time we only subscribed to those two.

Specific information about the article: it noted that while list was
better for insertion in the middle, it turns out that vector is almost
always fast enough. And by that I mean fast enough that the article
recommended just always using vector.
Interesting...
I'd like to reread this article, and it's driving me batty that I
can't just google "vector list comparison c++ article" and get
anything useful.
What if you add 'CUJ' to that? Or more of 'container' 'standard'
and some such?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Nov 1 '07 #2
On Nov 1, 12:02 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
mosw...@gmail.com wrote:
I remember it was co-written by two people, one of
which I *think* is Herb Sutter (but I may be way off-base on that).

If you aren't, you will find the article here:http://www.gotw.ca/publications/index.htm
Thanks for the link. I've searched there, and I'm starting to think
that I was incorrect about him being one of the authors.
>
I'm not positive if it was in the CUJ, either, as it could have been
Dr. Dobbs. I doubt it was in any other magazine, as I remember
reading it at work and at the time we only subscribed to those two.
Specific information about the article: it noted that while list was
better for insertion in the middle, it turns out that vector is almost
always fast enough. And by that I mean fast enough that the article
recommended just always using vector.

Interesting...
Yeah, which is why I want to reread it. I want to make sure I'm not
crazy, and the article really did recommend it.
>
I'd like to reread this article, and it's driving me batty that I
can't just google "vector list comparison c++ article" and get
anything useful.

What if you add 'CUJ' to that? Or more of 'container' 'standard'
and some such?
I don't know if I've tried permutations of 'container', I'll do some
more searching. Thanks for the idea.

Nov 1 '07 #3
On 2007-11-01 17:43, mo*****@gmail.com wrote:
I've been searching for a specific article for awhile now. About two
years ago (maybe longer) there was an article in the C/C++ User's
Journal that compared the performances of various stl containers.
Unfortunately, while I remember the topic, I don't remember much else,
so if anyone is inclined to help me find it, they'll have to do some
detective work. I remember it was co-written by two people, one of
which I *think* is Herb Sutter (but I may be way off-base on that).
I'm not positive if it was in the CUJ, either, as it could have been
Dr. Dobbs. I doubt it was in any other magazine, as I remember
reading it at work and at the time we only subscribed to those two.

Specific information about the article: it noted that while list was
better for insertion in the middle, it turns out that vector is almost
always fast enough. And by that I mean fast enough that the article
recommended just always using vector.
I just watched an interesting video[*] of a presentation that Sutter
did where (at the end) he talked about that, he also mentioned that some
or all the information from the talk would be in a DDJ article (the 3rd
or 4th instalment of the Effective Concurrency series).

If we are talking about the same thing then the point he was making was
that due to cache latency (and RAM for large collections) and the
speculative prefetching modern CPUs performs a traversal of a vector
from start to end (or in reverse) will be much faster (different
magnitude) then a traversal of a list or other node-based structure.

So if you will perform many traversals of the container but very few
insertions in the middle then a vector will be much faster, however if
you do only a few traversals but many insertions in the middle then I am
not so sure. As always (and as Sutter said) always measure.

* The video:
http://video.google.com/videoplay?do...69049736584770
Slides:
http://www.nwcpp.org/Downloads/2007/...re_-_NWCPP.pdf

The thing about efficiency of a list vs. a vector begins about one
and a half hour in (or page 22 of the slides).

--
Erik Wikström
Nov 1 '07 #4
On Nov 1, 10:41 pm, Erik Wikström <Erik-wikst...@telia.comwrote:
On 2007-11-01 17:43, mosw...@gmail.com wrote:
[...]
If we are talking about the same thing then the point he was
making was that due to cache latency (and RAM for large
collections) and the speculative prefetching modern CPUs
performs a traversal of a vector from start to end (or in
reverse) will be much faster (different magnitude) then a
traversal of a list or other node-based structure.
A vector generally does have better locality, but some list
implementations use various strategies to improve the locality
as well. Note too that if the objects in your vector use
dynamic memory (e.g. a vector of std::string), then you may not
have the locality anyway, even with vector.
So if you will perform many traversals of the container but
very few insertions in the middle then a vector will be much
faster, however if you do only a few traversals but many
insertions in the middle then I am not so sure. As always (and
as Sutter said) always measure.
Always measure. If your copy constructor and assignment
operator are very expensive (e.g. a deep copy of dynamically
allocated memory), insertion in the middle of a vector becomes
very expensive. If they're cheap (e.g. for int), you have to
copy an awful lot for the cost to be as high as the dynamic
allocation a list typically needs (but here, too, some
implementations have more or less effective optimization
strategies).

Anytime you read global statements as to which container is
faster, be suspicious, because the only correct global answer
is: "it all depends".

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

Nov 2 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Michi | last post by:
I was wondering what the best solution is for making large numbers of TEXT (or BLOB?) fields searchable. For example, if I have a forum, what is the best way to be able to search for specific...
5
by: Alan Mackenzie | last post by:
I've recently moved onto a C++ project with a large number of directories (several hundred) containing an even larger number of C++ source files. There are vastly more ways in C++ to obfuscate a...
1
by: anu | last post by:
helloo iam working on a parser wherein i search for a few strings in thousands of lines... ie i have an open fifo from which i keep receiving lines and lines of data and iam supposed to search...
5
by: jatin.libra | last post by:
helloo iam working on a parser wherein i search for a few strings in thousands of lines... ie i have an open fifo from which i keep receiving lines and lines of data and iam supposed to search...
5
by: Ada | last post by:
hello folks, just wanna get some feedback from someone here who has more experience. :-) i'm developing a small app that require searching for the highest index within a directory. i was...
33
by: Geoff Jones | last post by:
Hiya I have a DataTable containing thousands of records. Each record has a primary key field called "ID" and another field called "PRODUCT" I want to retrieve the rows that satisy the following...
11
by: Michele and John | last post by:
I would like to write a C++ program that searches for the variable "state != 0" in a text file, and then go back 3 steps each time to read "count". The program should create a new file with "state ...
8
by: sandeep | last post by:
Our team is developing proxy server(in VC++)which can handle 5000 clients. I have to implement cache part so when ever a new request com from client I have to check the request URL content is in...
2
by: programmo | last post by:
I need to divide in two string an article, to split in more pages: I have this string: <hello word> <hello word2>
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.