Limit std::sort comparisons on small list

Paolo Carlini paolo.carlini@oracle.com
Thu Oct 3 20:53:00 GMT 2013


Hi,

On 10/03/2013 10:04 PM, François Dumont wrote:
> So no impact on sort because the number of elements involved is too 
> important. Good, even if limited, impact on stable_sort because it 
> reduces the number of comparison by about 0.5% in the random case. I 
> have added a test to check that on small number of elements it has the 
> expected impact, only 1 comparison when 2 elements in the array.
Thanks for your help on this. While we wait for comments from Chris, 
Marc and other interested people, I have a rather simple-minded question 
for you: how would you explain that the number of comparisons for the 
sort performance tests remains *exactly* the same, while we know that 
the change helps for 2 elements, avoiding a comparison? Isn't navely 
weird that a similar situation *never* happens for the performance 
tests? Surely it does happen if we change the random seed of the random 
variant, at least an handful of times?!?

Thanks again,
Paolo.



More information about the Libstdc++ mailing list