countCalls | R Documentation |
These functions allow one to count the number of calls to one or more functions.
countCalls(obj, counter = genCounter(), env = globalenv(), print = FALSE)
countMCalls(..., counter = genMultiCounter(funNames), env = globalenv(), print = FALSE,
funs = substitute(list(...))[-1],
funNames = sapply(funs, as.character))
obj,... |
the functions either as quoted namesto be |
counter |
the counter object to use, typically created via |
env |
the environment in which to evaluate the call to |
print |
passed on to |
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. |
funNames |
the names of the functions, typically computed from the call itself. These are used to make updating the counts more efficient by not having to check if there is already a named element for the function in the integer vector. |
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, or to create a new
empty integer vector if its parameter |
inc |
the function called to increment the counter |
Duncan Temple Lang
trace
ctr = countMCalls(rnorm)
replicate(10, rnorm(0))
ctr$value()
ctr$reset()
replicate(5, rnorm(0))
ctr$value()
ctr = countMCalls(dnorm, rnorm)
replicate(10, dnorm(0))
replicate(7, rnorm(1))
dnorm(1)
ctr$value()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.