[Rd] RE: [R] Benchmarking R, why sort() is so slow?
Peter Dalgaard BSA
p.dalgaard@biostat.ku.dk
28 Apr 2001 02:27:29 +0200
Ross Ihaka <ihaka@stat.auckland.ac.nz> writes:
> You may be overlooking a major reason for the slowness of the
> R sorting --- the fact that the element comparisons are not inlined.
> Comparisons dominate the cost of the sort, so any speedup of them
> will make sorting faster.
Hmm. I'd suspect that declaring them static would make gcc grab any
chance of inlining..
> It might be worth looking at replacing the present comparison
> function definitions with macros to see what sort of speedup
> you get. It might also be useful to try to take advantage of
> IEEE arithmetic behaviour, or perhaps do a pre-sweep of the
> data to first place the NAs and Infs in their correct positions
> at the start or the end, and so simplify the comparison code.
> This might prove a bigger win than a switch of algorithm.
This sounds like it would be worth trying.
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._