4 ms·
I wrote a personal benchmark suite specifically to compare the Javascript port of Timsort to my own 'pet' Javascript sorting module 'Barsort.js' which was speci
by strainer 8y ago
I wrote a personal benchmark suite specifically to compare the Javascript port of Timsort to my own 'pet' Javascript sorting module 'Barsort.js' which was specialised to sorting Numbers, while Timsort also does strings quickly and takes custom comparators.
I tested these distributions for arrays of 100 to 1000000 elements:
descending ints
ascending ints
descending ints with maveric vals
ascending ints with maveric vals
equally distributed reals from -20 to 20
gaussian distribution -1 to 1
midspiked reals with duplicates -200 to 200
huge magnitude with gaps and duplicates and infinites
equal-dist of ints 1 or 2
equal-dist of ints 1 2 3
equal-dist of ints 1 2 3 4
equal-dist of ints 1 2 3 4 5
Timsort seemed relatively a little slow with gaussian/normal and equal distributions, but still 10x faster or more than browsers native sort at the time.
I was able to extend my pet sorting module to be quite competitive with Timsort's Javascript port. It was a captivating side project that I escaped from as soon as tests passed, its code not in a decent state, but is here - https://github.com/strainer/barsort https://github.com/strainer/barsort