Last updated 17-11-2016 v1.04
The test setup is an E8500 (Core2Duo) on an Intel motherboard, 8GB ram, running GCC 5.1 x64 as compiler. Build settings are "-O2;-march=native;-std=c++11;-fomit-frame-pointer". Tests are based on a sliding scale of number of runs vs number of elements, so a test with only 10 elements in a container may average 100000 runs, whereas a test with 100000 elements may only average 10 runs. This tends to give adequate results without overly lengthening test times.
Tests are carried out on the following types: (a) a 8-bit type ie. char, (b) a 32-bit type ie. int, (c) a 64-bit type ie. double, (d) a small struct containing two pointers and four scalar types, and (e) a large struct containing 2 pointers, 4 scalar types, a large array of ints and a small array of chars. In order to better facilitate accurate time-keeping for short tests, both container construction and destruction times are included in the tests. The sequence is as follows: construction, push N elements, read (back) + pop all elements, destruction. Because unlike a regular container, a stack must be pushed for every pop, and popped for every read, it most sense to combine these two timings and compare on that basis, as what is most important is the overall time taken. For that reason both separate and combined ("total time") benchmarks are presented below.
Click images or hover over to see results at linear scale instead
Click images or hover over to see results at linear scale instead
Click images or hover over to see results at linear scale instead
Simply put, plf::stack out-performs both std::stack (std::deque) and std::vector once you take into account both push and pop time, and we can see that the larger the stored type is, the greater the performance advantage is.
Contact:
plf:: library and this site Copyright (c) 2021, Matthew Bentley