Re: Why is VC++ STL so slow?
David Alasiga wrote:
"Andrew Koenig" <ark@acm.org> wrote in message
news:QezTg.157017$QM6.121623@bgtnsc05-news.ops.worldnet.att.net...
"David Alasiga" <dialectics@yahoo.com> wrote in message
news:kkjTg.182$If3.172@trnddc07...
g++ linux version runs 80% fast than VC++ version
and g++ Cygwin version (running on windows) runs 50% fast than VC++
version.
Could it be that you are running VC++ in debug mode?
No. I am running VC++ in release mode. I think something definitely
wrong with the implementation of set and map. I used a set to insert
some items and do some searching. However, the set is so slow that I
have to use a vector then sort the vector instead of using set. Vectors
are easy to be implemented but sets and maps are implemeted using some
kind of balanced tree. In theory, the performance of set should be
better than vector for searching. But in my case, the vector is far
better than the set. Then I have the performance issue with the map.
That forces me to think that the VC++ STL has fundamental problems.
This is not correct. If you only do searching, std::vector will be
superior to std::map or std::set, so if you have a collection and only
use it for searching, it will always be better to use a std::vector.
[OT advice]
Another issue is that the Microsoft STL by default has some checking
enabled, that invariably makes the code slower - and this might be
visible if a large proportion of the time is spent in STL code. Apart
from setting the optimisation flags correctly, You have to add some
defines in order to remove those checks (consult your manual to see
how). I've heard that removing these "release mode" checks can double
your performance.
/Peter
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]