What is the "user" and "system" measurement time in R system.time (exp) output?

I use system.time(expression) to measure the runtime for function R.

The result that I get for the call

 system.time(myfunction()) 

is an:

  user system elapsed 117.36 5.65 127.86 

What measures "user" and "system"?

+64
time r
Apr 16 '11 at 19:21
source share
5 answers

This is discussed in ?proc.time ( system.time() returns an object of class "proc.time" ):

 Details: '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. 

.... and

 Value: .... The definition of 'user' and 'system' times is from your OS. Typically it is something like _The 'user time' is the CPU time charged for the execution of user instructions of the calling process. The 'system time' is the CPU time charged for execution by the system on behalf of the calling process._ 
+35
Apr 16 '11 at 19:28
source share

The clearest explanation I've ever read about the difference between user and system elapsed time was provided by William Dunlap in [R-help] :

"User processor time" gives the processor time spent on the current process (that is, the current R session) and "CPU system time" gives the CPU the time spent by the kernel (operating system) on behalf of the current process. The operating system is used to open files, perform input or output, start other processes and look at the system clock: operations that are associated with resources that many processes must share.

Although ?proc.time returns something similar, this description was much easier to understand for me.

+30
May 03 '14 at 16:39
source share

Since they are still common, from Wikipedia:

The term "user processor time" may be a little misleading at first. To be clear, total time (real time of the processor) is a combination of CPU time spends some action on programs and CPU time spends system calls on the kernel on behalf of the program. When a program passes through an array, it accumulates user processor time. Conversely, when a program makes a system call, such as exec or fork, it accumulates the CPU system time.

http://en.wikipedia.org/wiki/Time_(Unix)#User_Time_vs_System_Time

+13
Apr 16 '11 at 19:30
source share

Here are some simple explanations:

Elapsed time is the time taken by the processor to express.

User time is the wall clock time. The time you experienced as a user.

Usually both points are relatively close. But they may vary in some other situations. For example:

  • If elapsed time> user time , this means that the CPU is waiting for some other operations (may be external).
  • If the elapsed time is <user time , this means that your computer has several cores and can use them.
+2
Feb 26 '17 at 17:09 on
source share

Since these temporary variables are defined by your OS, you can get information about how they are calculated by executing man time in your shell (on Unix):

... These statistics consist of (i) the elapsed real time between the call and the termination, (ii) the CPU time of the user (the sum of the tms_utime and tms_cutime in the tms structure returned by the times (2)) and (iii) the CPU system time (the sum tms_stime and tms_cstime in the tms structure, returned from time to time (2)).

The definition of these temporary variables can be found here :

tms_utime User CPU time.

tms_stime time.

tms_cutime Custom processor time for completed child processes.

tms_cstime System processor time of completed child processes.

A clarification of the differences between user and system time is described in daroczig's answer and elsewhere on SO :

The tms_utime element is the amount of time it takes to execute your code, or the code in the C library. The tms_stime element is the amount of time it takes to execute the kernel code on your behalf.

0
Feb 16 '17 at 14:26
source share



All Articles