powered by
Wrap a function with a timer.
time_it(func, units = "auto", digits = 2)
(closure) An object that contains the original function bound to the environment of the decorator.
closure
(function) A function to decorate.
function
(character) Units in which the results are desired, including: "auto", "secs", "mins", "hours", "days", and "weeks". See difftime.
character
"auto"
"secs"
"mins"
"hours"
"days"
"weeks"
(integer) The number of significant digits to be used. See signif.
integer
timeit Python module
Closures in R
Sys.sleep <- time_it(base::Sys.sleep) Sys.sleep(0.1)
Run the code above in your browser using DataLab