time_it: Measure Execution Time of Functions

View source: R/decorator-time_it.R

time_itR Documentation

Measure Execution Time of Functions

Description

Wrap a function with a timer.

Usage

time_it(func, units = "auto", digits = 2)

Arguments

func

(function) A function to decorate.

units

(character) Units in which the results are desired, including: "auto", "secs", "mins", "hours", "days", and "weeks". See difftime.

digits

(integer) The number of significant digits to be used. See signif.

Value

(closure) An object that contains the original function bound to the environment of the decorator.

References

Examples

Sys.sleep <- time_it(base::Sys.sleep)
Sys.sleep(0.1)

decorators documentation built on Sept. 30, 2022, 5:06 p.m.