[R] total CPU time in Matlab - what is the equivalent in R?

William Dunlap wdunlap at tibco.com
Mon Aug 27 16:38:26 CEST 2012


I didn't notice a discussion of what system or user time meant in
those two articles.  (The first correctly says that system.time() is
a more convenient way to time things, as it calls proc.time() before
and after your expression and subtracts.  It also does garbage
collection before the timing, so you get more consistent results.)

CPU time is essentially user time plus system time.   User time is time spent
in R itself.  System time is time spent by the kernel of the operating
system doing things that R asked it to do (e.g., finding a file, reading
a file, perhaps getting the time).  What is considered system time
depends on your operating system.  There is some time spent switching
between user and kernel mode and I don't know who gets charged for
that time.  Elapsed time is usually what counts in the end.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
> Of Jeff Newmiller
> Sent: Sunday, August 26, 2012 11:13 PM
> To: Gopi Goteti; r-help at r-project.org
> Subject: Re: [R] total CPU time in Matlab - what is the equivalent in R?
> 
> Google is your friend
> 
> http://www.ats.ucla.edu/stat/r/faq/timing_code.htm
> 
> http://r.research.att.com/benchmarks/
> ---------------------------------------------------------------------------
> Jeff Newmiller                        The     .....       .....  Go Live...
> DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
>                                       Live:   OO#.. Dead: OO#..  Playing
> Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
> /Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
> ---------------------------------------------------------------------------
> Sent from my phone. Please excuse my brevity.
> 
> Gopi Goteti <gopi.goteti at gmail.com> wrote:
> 
> >I am trying to compare the speed of my R code with that reported by the
> >authors of a reference paper who used Matlab. The authors of the paper
> >state "Total CPU time for the algorithm was 10 s for the ...on a modest
> >mobile 2.2 GHz Pentium processor running MATLAB v.6".
> >
> >I am using proc.time (similar to the example shown in ?proc.time) to
> >determine the speed of my R code. Could someone please tell me whether
> >"user" time or "system" time is the equivalent of total CPU time
> >reported
> >by Matlab.
> >
> >Thanks
> >GG
> >
> >	[[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.
> 
> ______________________________________________
> 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