STL Performance comparison, gcc 4.5.1 vs STLPort 4.5

Taking Alan Ning STL performance comparison of VC9, VC10 and STLPort I converted it over for Linux (available here) and compared the built in STL of gcc 4.5.1 on x86_64 versus STLPort 4.5 both at -O2. Tests and test-descriptions below are lifted directly from Alan. Times are actually in milliseconds, not seconds, but I didn’t bother regenerating the graph legends.

Lower bars are better, hardware is an i7 with 6 gigs memory.

The test for vector involves three operations – insertion, iterator traversal, and copy.

Native STL consistently faster.


Native STL consistently faster.

The test for string involves three operations – string copy, substring search, and concatenation.

Native STL apparently worse with strings with approx more than 3200 characters.


Native STL typically slower.

The test for map involves insertion, search, and deletion.

Native STL typically worse with maps over 200 elements.


Native STL typically faster.

The test for Deque comes with a twist. The deque is implemented is as a priority queue through make_heap(), push_heap() and pop_heap(). Random items are inserted and removed from the queue upon each iteration.

Native STL faster.


Native STL faster.

In general the gcc STL looks comparatively good with the exception of large maps.

5 Responses to “STL Performance comparison, gcc 4.5.1 vs STLPort 4.5”

  1. Arpad Borsos says:

    Would be also interesting to see how libc++ from llvm is doing compared to gcc.

  2. Maxim Yanchenko says:

    Why STLPort 4.5, not 5.2.1?

  3. Caolan says:

    Because that’s the version that OOo builds against by default so I had it handy for comparison.

  4. Philipp Weissenbacher says:

    May I bring this stackexchange discussion to you attention?
    http://stackoverflow.com/questions/604050/switch-from-microsofts-stl-to-stlport

    Though there are no numbers, one can find some anecdotes on STL (esp. MSVC) vs. STLPort.

  5. Miroslav Rubanets says:

    Just run the benchmark in our environment. Its a pity that getting pictures requires too much manual labour.
    There are differences in typical production for us. First we are using currently g++ (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48) and we using StlPort 5.2.1.
    Overall score for g++ stl is not bad but some tests fail badly.
    Its nice to see that when corporate guys in red hat will move to 4.5.2+ we will have an option of dropping StlPort for Linux.

Leave a Reply