Description Usage Arguments Details Value See Also Examples
Return CPU (and other) times that expr
used.
1 2 | system.time(expr, gcFirst = TRUE)
unix.time(expr, gcFirst = TRUE)
|
expr |
Valid R expression to be timed. |
gcFirst |
Logical - should a garbage collection be performed
immediately before the timing? Default is |
system.time
calls the function proc.time
,
evaluates expr
, and then calls proc.time
once more,
returning the difference between the two proc.time
calls.
unix.time
is an alias of system.time
, for
compatibility with S.
Timings of evaluations of the same expression can vary considerably
depending on whether the evaluation triggers a garbage collection. When
gcFirst
is TRUE
a garbage collection (gc
)
will be performed immediately before the evaluation of expr
.
This will usually produce more consistent timings.
A object of class "proc_time"
: see
proc.time
for details.
proc.time
, time
which is for time series.
Sys.time
to get the current date & time.
1 2 3 4 5 6 7 8 9 10 11 12 | require(stats)
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
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.