C++ 20 Feb 2012 16:12:15

C++ Set Performance 2

(Old version from 2010-04-02)

A performance comparison of the speed of operations on the various set implementations used in C++. There are 16383 unique elements across which 1000000 insert, lookup, iterate, and erase operations are performed.

The raw tick numbers are shown and table sorting is enabled so you can compare for yourself. Just be aware that the Mac OS X, Linux, and Windows numbers cannot be compared against each other.

The full source is available in svn as a CMake project for easy cross-platform testing.

Sources

Mac OS X: XCode 4.3, clang++ 3.1

  • Compiler: XCode 4.3, clang++ 3.1 -std=c++0x -stdlib=libc++ -O3
  • Arch: OS X 10.7.3, 2.3 GHz Core i5, 8 GiB RAM

Key: uint32_t

InsertLookupIterateErase
std::set26337745528086927562919324794998
std::unordered_set692344505267579918523134318200
boost::unordered_set494414523266716222539416729997
CG3::interval_vector4043406888926133347936881367
CG3::sorted_vector2625655852281776232203041777348
CG3::sorted_deque4037033044073970834291957932190

Key: std::string

InsertLookupIterateErase
std::set71000940062301461371071966799492
std::unordered_set18430390017791193339260058224362
boost::unordered_set16934332415649689141354425611101
CG3::sorted_vector2035974542672658549428541478839543
CG3::sorted_deque152605911188135323466730820882673

Windows: MSVC++ 2010

  • Compiler: MSVC++ 2010 _SECURE_SCL=0
  • Arch: Windows 7 64 bit, 1.60GHz Core i7 Q720, 8 GiB RAM

Key: uint32_t

InsertLookupIterateErase
std::set30842930230476661879265452157740
std::unordered_set2111565287716020710359475309750
boost::unordered_set50913566294166082310718599725
CG3::interval_vector5836847853816544399254982686
CG3::sorted_vector4205813761943778311877449828559
CG3::sorted_deque1504499129447390205236772709469976
sti::sset1986372361825234365607233885912

Key: std::string

InsertLookupIterateErase
std::set729799112723706519822293103106061
std::unordered_set28496403012658295832622990685117
boost::unordered_set17111101915824733050599815771730
CG3::sorted_vector1531939079759340481405701318279702
CG3::sorted_deque211997338410969729452455671162315971
sti::sset4911879444780221908702090344926

Linux: GNU g++ 4.6.2

  • Compiler: GNU g++ 4.6.2 -std=c++0x -O3
  • Arch: VirtualBox on the Windows machine, VT-x, Arch Linux, kernel 3.2.6-2-ARCH, 1 GiB RAM

Key: uint32_t

InsertLookupIterateErase
std::set29212248626887303385630126172092
std::unordered_set255261002160575216121719461025
boost::unordered_set40030522333416281706375748189
CG3::interval_vector3924925552263953424440209203
CG3::sorted_vector1957841441735780011190834183587
CG3::sorted_deque3010308882799378702496046249722

Key: std::string

InsertLookupIterateErase
std::set92088656192320910692979382456296
std::unordered_set15682885414917958946540265240381
boost::unordered_set15772013116185342638612714208955
CG3::sorted_vector1457335009100212488097574788909210
CG3::sorted_deque14703386161119832233107800485375053

Subscribe to the comments through RSS Feed

Leave a Reply

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image