fastSort benchmarking (was Re: Work done so far)

bearophile bearophileHUGS at lycos.com
Mon Jan 21 04:14:20 PST 2008


Matti Niemenmaa:
> It appears to do a lot of comparing, though---and thus, when made to use a 
> custom comparing function instead of the built-in "<" operator it quickly slows 
> down. It's still much better than the built-in sort (especially since the 
> built-in sort can't even take a custom comparator), but for a more general sort 
> it's not that great.

I see. Notes:
- Two or more sorts can be kept, one for native data, one for more complex sorting, etc. (That's what I do in my d libs)
- Some of the situations where you use cmp() can be managed with a string mixin, maybe this can speed things up some.
- A better support of inlining by DMD may change the situation some.
- In many simple situations where speed and data size are less important a key() function is simpler to use than cmp(). See sorted/sortedAA in d libs. If uou use a key() you often don't need a cmp() too.
- Try adapting Timsort used by Python, probably it's not easy to find something better: http://py-stablesort.sourceforge.net/

Bye,
bearophile



More information about the Digitalmars-d mailing list