diff --git a/DESCRIPTION b/DESCRIPTION index f57cecf..503af5a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -18,7 +18,7 @@ Imports: profmem, rlang (>= 0.2.0), stats, - tibble, + tibble (>= 3.0.1), utils Suggests: covr, @@ -38,4 +38,4 @@ Suggests: Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.0.2 +RoxygenNote: 7.1.0 diff --git a/NEWS.md b/NEWS.md index 7c1c7c1..bc776aa 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # bench (development version) +* `bench::mark()` and `bench::workout()` no longer support unquote + and splice operators. This fixes inconsistencies in performance + results with functions like `rlang::list2()` (#61). + * `autoplot.bench_mark()` again supports factor levels for `expression`, as intended (#82) # bench 1.1.1 diff --git a/R/mark.R b/R/mark.R index 9e32947..0b4d824 100644 --- a/R/mark.R +++ b/R/mark.R @@ -58,7 +58,7 @@ mark <- function(..., min_time = .5, iterations = NULL, min_iterations = 1, } if (is.null(exprs)) { - exprs <- rlang::exprs(...) + exprs <- dots(...) } n_exprs <- length(exprs) @@ -130,7 +130,7 @@ mark <- function(..., min_time = .5, iterations = NULL, min_iterations = 1, results$gc[[i]] <- parse_gc(gc_msg) } - out <- summary(bench_mark(tibble::as_tibble(results, validate = FALSE)), + out <- summary(bench_mark(tibble::as_tibble(results, .name_repair = "minimal")), filter_gc = filter_gc, relative = relative, time_unit = time_unit) file <- getOption("bench.file", NULL) diff --git a/R/utils.R b/R/utils.R index dc79ad6..a71cda1 100644 --- a/R/utils.R +++ b/R/utils.R @@ -122,3 +122,14 @@ find_package_root <- function(path) { is_root <- function(path) { identical(path, dirname(path)) } + +dots <- function(...) { + dots <- as.list(substitute(...())) + + n <- length(dots) + if (n && rlang::is_missing(dots[[n]])) { + dots <- dots[-n] + } + + dots +} diff --git a/R/workout.R b/R/workout.R index 5178243..ff3b450 100644 --- a/R/workout.R +++ b/R/workout.R @@ -24,12 +24,12 @@ #' # The equivalent to the above, reading the code from a file #' workout_expressions(as.list(parse(system.file("examples/exprs.R", package = "bench")))) workout <- function(expr, description = NULL) { - expr <- rlang::enquo(expr) - env <- rlang::quo_get_env(expr) - if (rlang::quo_get_expr(expr)[[1]] == "{") { - exprs <- as.list(rlang::quo_get_expr(expr)[-1]) + expr <- substitute(expr) + env <- parent.frame() + if (rlang::is_call(expr, "{")) { + exprs <- as.list(expr[-1]) } else { - exprs <- list(rlang::quo_get_expr(expr)) + exprs <- list(expr) } workout_expressions(exprs, env, description) } diff --git a/man/autoplot.bench_mark.Rd b/man/autoplot.bench_mark.Rd index c2eb684..d8053a0 100644 --- a/man/autoplot.bench_mark.Rd +++ b/man/autoplot.bench_mark.Rd @@ -5,7 +5,7 @@ \alias{plot.bench_mark} \title{Autoplot method for bench_mark objects} \usage{ -\method{autoplot}{bench_mark}( +autoplot.bench_mark( object, type = c("beeswarm", "jitter", "ridge", "boxplot", "violin"), ... diff --git a/man/bench-package.Rd b/man/bench-package.Rd index 8172dd7..4998153 100644 --- a/man/bench-package.Rd +++ b/man/bench-package.Rd @@ -26,6 +26,7 @@ summary(results, relative = TRUE) \seealso{ Useful links: \itemize{ + \item \url{http://bench.r-lib.org/} \item \url{https://github.com/r-lib/bench} \item Report bugs at \url{https://github.com/r-lib/bench/issues} } diff --git a/man/bench_load_average.Rd b/man/bench_load_average.Rd new file mode 100644 index 0000000..39f05b8 --- /dev/null +++ b/man/bench_load_average.Rd @@ -0,0 +1,11 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/load.R +\name{bench_load_average} +\alias{bench_load_average} +\title{Get system load averages} +\usage{ +bench_load_average() +} +\description{ +Uses OS system APIs to return the load average for the past 1, 5 and 15 minutes. +}