Skip to content
Prev 10930 / 398502 Next

Benchmarking R, why sort() is so slow?

On Fri, 27 Apr 2001, Philippe Grosjean wrote:

            
I find it hard to believe that doing anything useful with a 1.1 million
length vector will not take very much longer than complete sorting, which
is a rare problem in statistics (not needed for quantiles, for example).
That's the problem with these benchmarks, they don't test realistic
problems because many of the packages concerned would need days of coding
to run one.

FWIW, there are O(n log n) sort algorithms, worst case, that are fairly
competitive on average too.  But testing random vectors is not
representation of real problems, and for many such (and even for
rnorm(1e6)) one can do even better by e.g radix sorting.  So if you know
something about the input you make your package look better. Again,
a problem with benchmarking.
There are several shellsort variants.  I would need to look up the
known results for precisely this one.