Description Usage Arguments Details Value Author(s) See Also Examples
Times the execution of an expression
1 2 |
expr |
Any R |
units |
A character expression long enough to uniquely identify one of "automatic", "seconds", "minutes", or "hours". Defaults to "automatic". |
return.time |
|
verbose |
|
If units = "automatic"
, then the units are choosen according to the
following rule: If the duration is < 2 min, use seconds. Else if duration
< 2 hours, use minutes. Else if < 2 days, use hours. Otherwise, use days.
If return.time = FALSE
, invisibly returns the evaluation of
expr
. If return.time = TRUE
, invisibly returns a list with
the following components:
out |
The evaluation of |
elapsed |
The elapsed time to evaluate |
units |
The time units of the elapsed time |
Landon Sego
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # We can assign the object within the call to timeIt():
timeIt(x1 <- rnorm(10^6))
str(x1)
# We can just run the expression without assigning it to anything
timeIt(rnorm(10^7), units = "m")
# Or we can assign the result externally
x2 <- timeIt(rnorm(10^7))
str(x2)
# To store the elapsed time:
x3 <- timeIt(rnorm(10^7), verbose = FALSE, return.time = TRUE)
x3[c("elapsed","units")]
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.