Reverse the list
Let’s test something more useful with a reverse operation. The reverse member function is used to reverse all the containers.
Let’s see how they perform:
The intrusive versions are about 25% faster than standard list. Even if reversal does not need to access the values, the pointers of the intrusive lists have a better locality than the one of a list that can be dispersed through memory.
The performance improved a bit, to 30% improvement for an intrusive list.
Let’s see if this continue:
It did, the intrusive list is more than 40% faster than the standard list !
What happens a bigger one:
The lines have been interchanged! This time the standard list is about 25% faster than the intrusive versions. This time, the better locality of the intrusive versions is not a gain but a loss.
It is logical that the margin decrease with very big objects during reversal. Indeed, each element is very close one to another, but the pairs of pointers are separated by the size of the data type. The bigger the data type, the higher distance between the pointers and so the worse spatial locality for the pointers. However, I do not explain why there is this big difference…
The performance of intrusive list are clearly interesting for reversing collection of small data types. However, it seems that for high data types, the standard list is faster.