[R] system.time question

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Oct 20 18:57:59 CEST 2012


On 20/10/2012 17:16, Mark Leeds wrote:
> Hi : I looked at the help for system.time but I still have the following
> question. Can someone explain the output following output
> of system.time :
>
>   user          system      elapsed
> 12399.681  5632.352   56935.647

Yes, the help page can, via ?proc.time.  As it says, it depends on the OS

> Here's my take based on the fact that I was doing ps -aux | grep R off and
> on and the total amount of CPU minutes that
> got allotted before the job ended was about 5 hours and the total actual
> time that the job took was about 15 hours.
>
> Does elapsed = total actual time job taken ? That seems to be the case or a
> strange coincidence.
>
> Does user + system = CPU time from ps -aux | grep R ? That seems to be the
> case also or a weird coincidence.

On Fedora Linux, yes.  Not in general (and what ps gives is pretty 
OS-specific: for example, does it include time from child processes or 
not -- system.time should but the OS calls used do not always do so, I 
find less reliably so in Fedora 16 than 14).

> Finally, why can't the CPU get a higher percentage ? It's seems like it's
> always around 30% which would make sense since
> 5 is ~ 30% of 15 hours.

Many, many reasons.  Most likely

- other things are running, and some of them have a higher priority, or 
equal or lower priority and get lots of time slices ....

- R the process is waiting for resources, such as memory, discs, network 
access ....

> Also, assuming my take above is correct, when talking about timing of
> algorithms, in this case, does one say the job took 5 hours or 15 hours ?
> I'm trying to see how fast an algorithm is compared to others and I'm not
> sure what the standard is.  I'm on fedora 16.0 and using R 2.15. Thanks.

It depends on the purpose.  CRAN's check farm cares most about CPU 
usage: someone waiting for results cares about elapsed time.

>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


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