This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Limit std::sort comparisons on small list


On 10/03/2013 10:59 PM, Paolo Carlini wrote:
.. or, if I remember correctly, should we maybe see what happens for a smaller or much smaller number of elements to see if there is a measurable (in number of comparisons terms), on sort?

Thanks,
Paolo.

I run the sort performance test using only 11 elements and in this case I see:

Without patch:
sort.cc reverse 10 comparisons 0r 0u 0s 0mem 0pf sort.cc forwards 20 comparisons 0r 0u 0s 0mem 0pf sort.cc random 30 comparisons 0r 0u 0s 0mem 0pf

With patch:
sort.cc reverse 10 comparisons 0r 0u 0s 0mem 0pf sort.cc forwards 19 comparisons 0r 0u 0s 0mem 0pf sort.cc random 29 comparisons 0r 0u 0s 0mem 0pf

so with a limited number of elements we can see the gain even if it looks like for the sort algo it is limited to 1 comparison. For stable_sort it is better.

FranÃois


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]