[R] slower execution in R 1.9.0
Prof Brian Ripley
ripley at stats.ox.ac.uk
Fri Apr 23 09:44:41 CEST 2004
Rather a misleading subject, if it was slower under 1.8.1.
On Thu, 22 Apr 2004, Scott Bartell wrote:
> I have an R function (about 1000 lines long) that takes more than 20
> times as long to run under R Windows 1.9.0 and 1.8.1 than it does under
> 1.7.1. Profile results indicate that the $<-.data.frame operation is
> the culprit, but I don't understand exactly what that is (assignment of
> data frame elements to another variable?), or why it's only a problem
> under 1.8.1 and 1.9.0. Any advice?
Don't use $<- on data frames, that is code like
foo$bar <- bah
for foo a data frame, if you don't want to pay the penalty of error
checking. Versions prior to R 1.8.0 treated data frames as lists for that
construct, and often ended up with invalid data frames.
Sound like you could use a lists for your working data.
>
> top 5 operations under 1.9.0
> self.time self.pct total.time total.pct
> $<-.data.frame 110.64 93.3 110.68 93.3
> FMD 5.38 4.5 118.60 100.0
> DIRinf 0.54 0.5 11.82 10.0
> INDinf 0.46 0.4 9.78 8.2
> pweibull 0.38 0.3 0.38 0.3
>
> top 5 operations under 1.7.1
> self.time self.pct total.time total.pct
> pweibull 2.62 55.7 2.62 55.7
> ^ 0.76 16.2 0.76 16.2
> CalcDistance 0.16 3.4 1.26 26.8
> FMD 0.16 3.4 4.70 100.0
> matrix 0.14 3.0 0.14 3.0
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list