genFunTimer: Measure the time for calls to a function via 'trace'

Description Usage Arguments Value Author(s) See Also Examples

View source: R/timeFun.R

Description

This function arranges to monitor all calls (direct or indirect) to the specified function and measures the time each call took and stores that value which can be accessed at any time via the return value of this function. This use trace to run the timing code at the start and end of each call to the function.

To stop collecting the timings for the function, untrace it.

Usage

1
timeFun(fun, tmr = genFunTimer(), where = globalenv(), ...)

Arguments

fun

the function or name of the function to trace

tmr

the list of functions closure whose start and end elements will be used to compute and store the timings.

where

passed to trace

...

passed to trace

Value

A list with three elements, allfunctions.

start

use with trace to

Author(s)

Duncan Temple Lang

See Also

trace

Examples

1
2
3
4
5
tmr = timeFun(model.matrix)
lm(mpg ~ . , mtcars)
tmr$times()
invisible(replicate(10, lm(mpg ~ . , mtcars)))
tmr$times()

duncantl/CallCounter documentation built on Jan. 20, 2020, 5:16 a.m.