summaryrefslogtreecommitdiffstats
path: root/Lib/test/sortperf.py
Commit message (Collapse)AuthorAgeFilesLines
* New test %sort. This takes a sorted list, picks 1% of the list positionsTim Peters2002-08-021-1/+7
| | | | | | | | | | | | | | | | at random, and replaces the elements at those positions with new random values. I was pleasantly surprised by how fast this goes! It's hard to conceive of an algorithm that could special-case for this effectively. Plus it's exactly what happens if a burst of gamma rays corrupts your sorted database on disk <wink>. i 2**i *sort ... %sort 15 32768 0.18 ... 0.03 16 65536 0.24 ... 0.04 17 131072 0.53 ... 0.08 18 262144 1.17 ... 0.16 19 524288 2.56 ... 0.35 20 1048576 5.54 ... 0.77
* New test "+sort", tacking 10 random floats on to the end of a sortedTim Peters2002-07-211-6/+9
| | | | | | | | | | array. Our samplesort special-cases the snot out of this, running about 12x faster than *sort. The experimental mergesort runs it about 8x faster than *sort without special-casing, but should really do better than that (when merging runs of different lengths, right now it only does something clever about finding where the second run begins in the first and where the first run ends in the second, and that's more of a temp-memory optimization).
* Added new test "3sort". This is sorted data but with 3 random exchanges.Tim Peters2002-07-201-1/+9
| | | | It's a little better than average for our sort.
* Gave this a facelift: "/" vs "//", whrandom vs random, etc. BoostedTim Peters2002-07-181-35/+46
| | | | | | | | | | | | | | the default range to end at 2**20 (machines are much faster now). Fixed what was quite a arguably a bug, explaining an old mystery: the "!sort" case here contructs what *was* a quadratic-time disaster for the old quicksort implementation. But under the current samplesort, it always ran much faster than *sort (the random case). This never made sense. Turns out it was because !sort was sorting an integer array, while all the other cases sort floats; and comparing ints goes much quicker than comparing floats in Python. After changing !sort to chew on floats instead, it's now slower than the random sort case, which makes more sense (but is just a few percent slower; samplesort is massively less sensitive to "bad patterns" than quicksort).
* Use random instead of whrandomAndrew M. Kuchling2002-04-101-3/+3
|
* String method conversion.Eric S. Raymond2001-02-091-3/+2
|
* Add Tim's worst case scenario.Guido van Rossum1998-05-261-6/+11
| | | | Revert to using whrandom so it will work with older versions of Python.
* Use random instead of whrandom.Guido van Rossum1998-05-201-4/+4
|
* Reduce memory requirements.Guido van Rossum1998-05-121-1/+4
|
* Add a few doc strings.Guido van Rossum1998-05-101-6/+31
|
* benchmark for list.sort()Guido van Rossum1998-05-101-0/+109