Learn R Programming

decorators (version 0.3.0)

time_it: Measure Execution Time of Functions

Description

Wrap a function with a timer.

Usage

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

Value

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

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.

References

Examples

Run this code
Sys.sleep <- time_it(base::Sys.sleep)
Sys.sleep(0.1)

Run the code above in your browser using DataLab