Iteration over a list
This time, we will test the iteration over a whole collection. The iterate is done with the C++11 foreach loop (taking a reference) and the data is used to increment a counter (to make sure the loop is not optimized away.
Let’s start with our small data type:
The standard list is indeed slower than the other versions (by about 20%). Which is expected due to their better data locality. However, the results are not very stable (probably too fast, many things can intervene). I was expecting better results.
Let’s go with a higher data type:
This time, the results look better, but there are less difference between the standard list and the intrusive versions. The intrusive versions are faster by about 10%.
If we take a bigger data type:
This time, there is no more difference between the different versions.
Just like the results for linear search, the intrusive versions are faster but the difference is not huge. For very small data type, there is a gain of about 15 to 20 percent, but on very big data types, there is no more increase in performance. Again, I would have expected better results for the intrusive versions.