[R] variations in how long commands take

About this list Date view Thread view Subject view Author view Attachment view

From: David Kane a296180@mica.fmr.com)
Date: Wed 18 Jul 2001 - 03:58:12 EST


Message-id: <15188.31924.840268.91001@gargle.gargle.HOWL>

We are performming a series of S+ 6.0 versus R 1.3 comparisons. (If anyone has
already written scripts for this purpose, we would be eager for a copy.) The
purpose is to see if there are any "gotchas" -- places were S+ works and R
doesn't -- that would prevent us from going all the way over to R. (We have
lots of legacy code, so the conversion costs are non-trivial.) As part of this
project, we have some simple matrix code that takes a similar amount of time in
S+ and in R (with R a little faster) the *first* time that we run it. However,
repeated invocations of this code in R produce slower and slower times (often
dramatically so). Here is a simple example (with a new R session):

> version
         _
platform sparc-sun-solaris2.6
arch sparc
os solaris2.6
system sparc, solaris2.6
status
major 1
minor 3.0
year 2001
month 06
day 22
language R

> m <- matrix(1, 400, 40000)
> proc.time(x0 <- apply(m, 2, sum))
[1] 21.88 3.16 40.13 0.00 0.00

So far, so good. This is more than twice as fast as the same thing in S+
6.0. But when I re-issue this command, I get:

> proc.time(x0 <- apply(m, 2, sum))
[1] 37.09 4.65 63.13 0.00 0.00
> proc.time(x0 <- apply(m, 2, sum))
[1] 52.34 5.44 85.29 0.00 0.00

So, my first question is: Why do the times keep going up? I first assumed that
there were some problems with overwriting x0 again and again, but I then remove
everything from the workspace and start "fresh":

> remove(list = ls())
> ls()
character(0)
> m <- matrix(1, 400, 40000)
> proc.time(x0 <- apply(m, 2, sum))
[1] 72.50 6.13 137.08 0.00 0.00

Second question is: Why does this continue even with an empty workspace? I do
not see this behavior in S+.

I have read ?Memory and played around with things like gc() and mem.limits(). I
am aware that R and S+ are very different in their memory usage. But I suspect
that there is something fundamental about R that I am missing . . .

Any suggestions or pointers would be much appreciated.

Thanks,

Dave Kane
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Wed 10 Mar 2004 - 08:18:20 EST