
Janos Vegh wrote:
Hi,
I was interested in the efficiacy of std::vector. Using the test program below, I receive the following results. The "simple" handling is equivalent with the C array access. The [] and iterator access time of the vector element is an order of magnitude worse, than that of the simple access. This is not because of index limit control, it is done by at() and its use increases that access time by a factor of three. What is going on in the background here, that the implementation is so ineffective? ( I did my tests with WinXP/cygwin/g++/time, using different setting of the #define-s at the beginning) Shall I expect similar ineffectivity with the other STL objects?
What optimization options did you use? There should be little difference in performance as long as the compiler inlines the vector access functions. Regards, /Patrik