doCallWE {simsalapar} | R Documentation |
Innermost Computation: Error Catching Version of do.call()
Description
doCallWE()
performs the innermost computation of the simulation
study at hand. It is a version of do.call(f, argl, *)
,
with care of catching and storing both error and warnings (via
tryCatch.W.E()
) and measures user time. This is useful
in large(r) simulation studies.
mkTimer()
returns a function to be passed as
timer
to doCallWE()
.
Usage
doCallWE(f, argl,
timer = mkTimer(gcFirst=FALSE))
mkTimer(gcFirst)
Arguments
f |
a |
argl |
list of arguments for |
timer |
a |
gcFirst |
logical, passed to |
Details
Note that gcFirst=FALSE
is default for a good reason: if a call
to doOne()
is relatively fast, calling gc()
every
time is unnecessarily expensive and may completely dominate the
overall simulation run time. For serious run time measurement,
gcFirst=TRUE
is preferable, as it ensures less
variable timings, see system.time
.
Value
doCallWE()
returns a list
with components
value |
|
error |
error message (see |
warning |
warning message (see |
time |
time, as measured by |
Author(s)
Marius Hofert and Martin Maechler.
See Also
Examples
set.seed(61)
L <- log(abs(rt(n=100, df = 1.5)))
r <- doCallWE(quantile, list(L, probs= 0.95))
## set timer for "no timing" :
u <- doCallWE(quantile, list(L, probs= 0.95), timer = function(E) { E; NULL })
stopifnot(is.null(r$error),
all.equal(r$value, quantile(L, 0.95)),
identical(r[1:3], u[1:3]), is.null(u[["time"]]))