I am using system.time(expression)
to measure execution time for an R function.
The output I get for the call
system.time(myfunction())
is:
user system elapsed
117.36 5.65 127.86
What does 'user' and 'system' measure?
I am using system.time(expression)
to measure execution time for an R function.
The output I get for the call
system.time(myfunction())
is:
user system elapsed
117.36 5.65 127.86
What does 'user' and 'system' measure?
This is discussed in
?proc.time
(system.time()
returns an object of class"proc.time"
):....and
Here is some simple explanations:
Elapsed Time is the time charged to the CPU(s) for the expression.
User Time is the wall clock time. The time that you as a user experienced.
Usually both times are relatively close. But they may vary in some other situations. For example:
Since those time variables are defined by your OS, you can retrieve information on how they are calculated by executing
man time
in your shell (on Unix):The definition of the mentioned time variables can be found here:
A a clarification of the differences between user and system time is described in daroczig's answer and elsewhere on SO:
Since these are generic anyway, from Wikipedia:
http://en.wikipedia.org/wiki/Time_(Unix)#User_Time_vs_System_Time
The clearest explanation I've ever read on the difference between
user
andsystem
elapsed time was provided by William Dunlap on [R-help]:Although
?proc.time
returns something similar, this description was a lot easier to understand for me.