R/bench_system_time.R

Defines functions bench_system_time

Documented in bench_system_time

#' Evaluate time of computation
#' @description (Used for examples and tests)
#' @param expr Passed to \code{\link[bench]{system_time}}.
#' @export
#'

bench_system_time <- function(expr) {
  # bench::system_time only evaluates expr in the
  # parent environment (reasonably). So we copy
  # the names of everything in expr so that
  # bench::system_time can run.
  for (`***` in all.vars(substitute(expr))) {
    assign(`***`, value = get(`***`, envir = parent.frame()))
  }
  if (requireNamespace("bench", quietly = TRUE)) {
    bench::system_time(expr)
  }
}

Try the hutilscpp package in your browser

Any scripts or data that you put into this service are public.

hutilscpp documentation built on Oct. 11, 2023, 9:06 a.m.