Return CPU (and other) times that expr used.
system.time(expr, gcFirst = TRUE)
<!-- %Deprecated unix.time(expr, gcFirst = TRUE) -->
| Parameter | Description |
|---|---|
expr |
Valid R expression to be timed. |
gcFirst |
Logical - should a garbage collection be performed immediately before the timing? Default is TRUE. |
# NOT RUN {
require(stats)
# }
# NOT RUN {
system.time(for(i in 1:100) mad(runif(1000)))
# }
# NOT RUN {
exT <- function(n = 10000) {
# Purpose: Test if system.time works ok; n: loop size
system.time(for(i in 1:n) x <- mean(rt(1000, df = 4)))
}
#-- Try to interrupt one of the following (using Ctrl-C / Escape):
exT() #- about 4 secs on a 2.5GHz Xeon
system.time(exT()) #~ +/- same
# }