countCalls: Count the number of calls to one or more functions

Description Usage Arguments Value Author(s) See Also Examples

View source: R/countCalls.R

Description

These functions allow one to count the number of calls to one or more functions.

Usage

1
2
3
countCalls(obj, counter = genCounter(), env = globalenv(), print = FALSE)
countMCalls(..., counter = genMultiCounter(), env = globalenv(), print = FALSE,
            funs = substitute(list(...))[-1])

Arguments

obj,...

the functions either as quoted namesto be

counter

the counter object to use, typically created via genCounter

env

the environment in which to evaluate the call to trace

print

passed on to trace

funs

an alternative way to specify the functions whose calls are to be counted. This allows the functions to be specified collectively in a list or character vector rather than individually via the ... mechanism.

Value

These function return the counter. This is a list with 3 functions

value

function to query the current count(s)

reset

function to reset the count(s) to 0

inc

the function called to increment the counter

Author(s)

Duncan Temple Lang

See Also

trace

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
ctr = countMCalls(rnorm)
replicate(10, rnorm(0))
ctr$value()


ctr = countMCalls(dnorm, rnorm)
replicate(10, dnorm(0))
replicate(7, rnorm(1))
dnorm(1)
ctr$value()

duncantl/CallCounter documentation built on April 19, 2018, 3:31 a.m.