Re: [R] sys.time question - how to improve R performance

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Sat, 26 Apr 2008 15:26:19 +0100 (BST)

On Sat, 26 Apr 2008, Ji Voller wrote:

> Dear R-users,
> I run my program a difference between sys.times is as follows:
> user system elapsed
> 60167.53 2848.75 63278.93
>
> I am quite puzzled how it may happen that system time is so much shorter
> than user time, I have 2 core computer most of the time (90%) I was not
> doing anything else with the computer. What could be the reason of such a
> difference? I switched off file indexing and all other resident
> programs...... My program include writing output into a file - could that be
> the reason?

First, do you mean system.time()? Its help page refers you to ?proc.time, which says:

      An object of class '"proc_time"' which is a numeric vector of
      length 5, containing the user, system, and total elapsed times for
      the currently running R process, and the cumulative sum of user
      and system times of any child processes spawned by it on which it
      has waited.  (The 'print' method combines the child times with
      those of the main process.)

and it seems you don't know those terms. At any given time a CPU is running a task for a process, it is either in a system call or in user code (R itself or a package). This is recorded every once in a while (a few ms) and totalled. So your process spent 2848s in system calls. The elapsed time is a little more than the sum of the user and system times, as your R session was not running 100% of the time.

You didn't even tell us your OS (see the posting guide) nor your background . On a Unix-alike look at the man pages for time and times. E.g. mine says

   The tms_utime field contains the CPU time spent executing instructions    of the calling process. The tms_stime field contains the CPU time    spent in the system while executing tasks on behalf of the calling process.

>
> Thanks for your replies.
>
> --
> --------------------------------------------------------------------------------------------
> Ji?? Voller
> Laboratory of Growth Regulators
> Palack? University & Institute of Experimental Botany AS CR
> ?lechtitel? 11, 783 71 Olomouc
> Czech Republic
> http://rustreg.upol.cz
> landline: +420-585-634-855
> cell: +420-737-520-506
> fax: +420-585-634-870
> ----------------------------------------------------------------------------------------------
>
> [[alternative HTML version deleted]]

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


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

Received on Sat 26 Apr 2008 - 14:29:52 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 26 Apr 2008 - 16:30:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive