[R] Benchmarking R, why sort() is so slow?

Philippe Grosjean phgrosje at ulb.ac.be
Fri Apr 27 15:18:13 CEST 2001


OK, I tested b <- sort(x) on x <- sample(1:100, 1100000, T), which gives
3.73 sec in my computer. In this case however, you have many ties. The
algorithm is thus much faster with ties (you don't expect much of them using
x <- rnorm(1100000)) or perhaps with integer numbers?

Still, the test for all 10 other software was done on a vector produced with
something similar to x <- rnorm(1100000). The second worst was Matlab 5.3
R11 (a little bit less than 8 sec... almost 3 times faster). Note also that
Splus 2000 pro R3 does the same test in less than... 2 seconds, 10 times
faster than R! This is not consistent at all with all other results where
Splus and R are close together (however, R is much faster than Splus in
loops, which is nothing new).

Philippe

-----Message d'origine-----
De : Torsten Hothorn [mailto:Torsten.Hothorn at rzmail.uni-erlangen.de]
Envoye : vendredi 27 avril 2001 14:55
A : Philippe Grosjean
Cc : r-help at stat.math.ethz.ch
Objet : Re: [R] Benchmarking R, why sort() is so slow?



> Hello everybody,
>
> I am making a modified version of "Stephan Steinhaus' benchmark test for
> number crunching, v. 2, (see
> http://www.scinetificweb.com/ncrunch/ncrunch.pdf for the original
version),
> comparing several functions of some math/stat software. R is not
performing
> bad at all... except for the sorting of a 1,100,000 random vector (test
#3)
> which is the worst of all (see cell F3 in the following table). I simply
> used the sort() function. Does anybody has an explanation for that?

it seems to depend:

R> x <- rnorm(1100000)
R> Rprof("sort.out")
R> b <- sort(x)

needs

hothorn at artemis:~ > R CMD Rprof sort.out

Each sample represents 0.02 seconds.
Total run time: 24.9399999999996 seconds.

but

R> x <- sample(1:100, 1100000, T)
R> Rprof("sort3.out")
R> b <- sort(x)

needs

hothorn at artemis:~ > R CMD Rprof sort3.out

Each sample represents 0.02 seconds.
Total run time: 4.2 seconds.

on a Intel PIII 450 MHz, 256 MB, SuSE Linux 6.3, R-1.2.3

Torsten


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list