run_time: Print the time taken to run an expression

Description Usage Arguments Value See Also

View source: R/util.R

Description

Sometimes you just want to know how long something took. There are many more elaborate solutions for more formal benchmarking (like microbenchmark), but for some applications you don't want to repeat an action or do formal benchmarking. This function simply evaluates the expression in 'expr' and outputs the time taken as a 'message'.

Usage

1
run_time(expr, message = NULL, digits = 2)

Arguments

expr

An expression to be evaluated.

message

A string describing what you're doing. This will be appended to the start of the printed message. For example, if you set 'message = "run things"' the output will look like 'Time taken to run things: 5.15 seconds'.

Value

The result of evaluating 'expr' in the environment from which 'run_time' was called.

See Also

'system.time' base R solution with more basic output.


lukerobert/luketools documentation built on Jan. 24, 2020, 2:15 a.m.