Running Time of R
proc.time determines how much real and CPU time (in seconds)
the currently running Rprocess has already taken.
proc.time returns five elements for backwards compatibility,
- 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 Rprocess, and the cumulative sum of user and system times of any child processes spawned by it on which it has waited. (The
summarymethod to combine the child times with those of the main process.) The definition of
userand systemtimes is from your OS. Typically it is something like
user timeis the CPU time charged for the execution of user instructions of the calling process. The system timeis the CPU time charged for execution by the system on behalf of the calling process.
Times of child processes are not available on Windows and will always be given as
The resolution of the times will be system-specific and on Unix-alikes times are rounded down to milliseconds. On modern systems they will be that accurate, but on older systems they might be accurate to 1/100 or 1/60 sec. They are typically available to 10ms on Windows.
This is a primitive function.
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
## a way to time an R expression: system.time is preferred ptm <- proc.time() for (i in 1:50) mad(stats::runif(500)) proc.time() - ptm