Learn R Programming

berryFunctions (version 1.11.0)

exTime: Time to run examples

Description

Time the execution of examples. Useful in package development to identify functions takeing much time.

Usage

exTime(topic, echo = FALSE, elapsed = FALSE, imagefile = TRUE, quiet = FALSE, ...)

Arguments

topic
Character string: the online help topic the examples of which should be run
echo
Show the R input when sourcing? DEFAULT: FALSE
elapsed
Return *only* the third element (total elapsed time)? DEFAULT: FALSE
imagefile
Reroute graphics to pdf device? Will message the tempfile location if quiet=FALSE. DEFAULT: TRUE
quiet
Suppress warnings with both suppressWarnings and suppressMessages, also capture.output for str and cat results as well as setting pboptions(type="none") if pbapply is available.
...
Further arguments to example, especially run.dontrun, run.donttest and package, but NOT character.only and ask

Value

Time used as per system.time

Warning

warningMayBeRemoved

See Also

example, system.time

Examples

Run this code
exTime("yearSample")
exTime("yearSample", quiet=TRUE)
exTime(yearSample) # does NOT work, gives NULL and warning
exTime("yearSample", elapsed=TRUE, quiet=TRUE)

## this takes quite some time if done for all functions in the package:
## Not run: 
# fn <- ls("package:berryFunctions")[1:7]
# ft <- rep(NA,length(fn))  ; names(ft) <- fn
# for(f in fn)  ft[f] <- exTime(f, quiet=TRUE, elapsed=TRUE, run.dontrun=FALSE)
# as.matrix(sort(ft))
# system2("open", tempdir()) # to view the pdf graphics created by exTime
# ## End(Not run)

Run the code above in your browser using DataLab