[R] Which system.time() component to use?

Gabor Grothendieck ggrothendieck at gmail.com
Sun Feb 28 03:46:57 CET 2010


Try this:

> system.time(Sys.sleep(60))
   user  system elapsed
   0.00    0.00   60.05
> pt <- proc.time(); Sys.sleep(60); proc.time() - pt
   user  system elapsed
   0.00    0.00   60.01

On Sat, Feb 27, 2010 at 9:33 PM, Ravi Varadhan <rvaradhan at jhmi.edu> wrote:
>
> Hi,
>
> The `system.time(expr)' command provide 3 different times for evaluating the expression `expr'; the first two are user and system CPUs and the third one is total elapsed time.  Suppose I want to compare two different computational procedures for performing the same task, which component of `system.time' is most meaningful in the sense that it most accurately reflects the computational effort of the algorithm, and does not depend upon the idiosyncrasies of the operating system.
>
> I have always been using the first component of `system.time', which is the user CPU.  Should I use the sum of user and system CPU or is the total elapsed time a better measure?  I would appreciate UseR's feedback on this.
>
> Thanks very much.
>
> Best,
> Ravi.
> ____________________________________________________________________
>
> Ravi Varadhan, Ph.D.
> Assistant Professor,
> Division of Geriatric Medicine and Gerontology
> School of Medicine
> Johns Hopkins University
>
> Ph. (410) 502-2619
> email: rvaradhan at jhmi.edu
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list