Learn R Programming

berryFunctions (version 1.18.2)

exTime: Time to run examples

Description

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

Usage

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

Arguments

topic

Character string: the online help topic of which the examples should be run.

package

Charstring: installed and loaded package from which all examples 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

See Also

example, system.time

Examples

Run this code
# NOT RUN {
exTime("plot")
exTime("yearSample", quiet=TRUE)
exTime(yearSample) # does NOT work, gives NULL and warning
exTime("yearSample", elapsed=TRUE, quiet=TRUE)
exTime("addFade", elapsed=TRUE, quiet=TRUE, run.dontrun=TRUE, run.donttest=TRUE)

## this takes quite some time if done for all functions in a package:
# }
# NOT RUN {
times <- exTime(package="rdwd")
as.matrix(sort(times))
system2("open", tempdir()) # to view the pdf graphics created by exTime

# times <- exTime(package="rdwd", run.dontrun=FALSE)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab