[R] unix.time

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Mar 26 17:52:21 CET 2008


Where did you get that idea from?  Not from the help page:

      'system.time' calls the function 'proc.time', evaluates 'expr',
      and then calls 'proc.time' once more, returning the difference
      between the two 'proc.time' calls.

      'unix.time' is an alias of 'system.time', for compatibility with
      S.

Value:

      A object of class '"proc_time"': see 'proc.time' for details.

and ?proc.time says

      'proc.time' returns five elements for backwards compatibility, but
      its 'print' method prints a named vector of length 3.  The first
      two entries are the total user and system CPU times of the current
      R process and any child processes on which it has waited, and the
      third entry is the ‘real’ elapsed time since the process was
      started.

So, you get measurements of user and system CPU time _and_ elapsed time. 
E.g.

> system.time(Sys.sleep(1.7))
    user  system elapsed
     0.0     0.0     1.7
> system.time(Sys.sleep(1.7))[3]
elapsed
    1.69


On Wed, 26 Mar 2008, Faheem Mitha wrote:

>
> Hi,
>
> As far as I can tell, The R function unix.time calculates elapsed CPU
> time. Is there a command within R to measure actual elapsed time (I think
> this is sometimes referred to as wall time)?
>
> For example, the time command from GNU time calculates the actual elapsed
> time, as far as I can tell.
>
> (Please CC me, I'm not subscribed.)
>                                                         Thanks, Faheem.
>
> ______________________________________________
> 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