From p.dalgaard@biostat.ku.dk  Sat Apr 28 01:27:29 2001
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 28 Apr 2001 02:27:29 +0200
Subject: [Rd] RE: [R] Benchmarking R, why sort() is so slow?
In-Reply-To: Ross Ihaka's message of "Sat, 28 Apr 2001 10:19:58 +1200"
References: <MABBLJDICACNFOLGIHJOIECDCDAA.phgrosje@ulb.ac.be> <Pine.A41.4.33.0104270814010.36572-100000@homer40.u.washington.edu> <15081.38439.622847.16842@gargle.gargle.HOWL> <3AE9F08E.2299A92A@stat.auckland.ac.nz>
Message-ID: <x2lmol7tse.fsf@blueberry.kubism.ku.dk>

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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] RE: [R] Benchmarking R, why sort() is so slow?
Peter Dalgaard BSA