From bcfe6e2034453a7bed79ff511168a788369774f2 Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Tue, 16 Jun 2020 17:51:52 +0200 Subject: [PATCH 1/4] Fix `as_tibble()` deprecation warning --- DESCRIPTION | 2 +- R/mark.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f57cecf..1117f01 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -18,7 +18,7 @@ Imports: profmem, rlang (>= 0.2.0), stats, - tibble, + tibble (>= 3.0.1), utils Suggests: covr, diff --git a/R/mark.R b/R/mark.R index 9e32947..6e11381 100644 --- a/R/mark.R +++ b/R/mark.R @@ -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) From 2f312690407677674c30cb5abb8ee9941f62f790 Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Tue, 16 Jun 2020 17:53:55 +0200 Subject: [PATCH 2/4] Avoid splicing eagerly Fixes #61 --- NEWS.md | 4 ++++ R/mark.R | 2 +- R/utils.R | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 7c1c7c1..35227d8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # bench (development version) +* `bench::mark()` no longer supports 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 6e11381..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) 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 +} From e4b0bb9d01f891a5eda15c5e190a9010e8d5b2d9 Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Tue, 16 Jun 2020 18:23:56 +0200 Subject: [PATCH 3/4] Redocument --- DESCRIPTION | 2 +- man/autoplot.bench_mark.Rd | 2 +- man/bench-package.Rd | 1 + man/bench_load_average.Rd | 11 +++++++++++ 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 man/bench_load_average.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 1117f01..503af5a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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/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. +} From 10d78c6f40ffc7adf5f2188794372a020687b169 Mon Sep 17 00:00:00 2001 From: Lionel Henry Date: Tue, 16 Jun 2020 18:36:24 +0200 Subject: [PATCH 4/4] Avoid unquoting in `bench::workout()` --- NEWS.md | 6 +++--- R/workout.R | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/NEWS.md b/NEWS.md index 35227d8..bc776aa 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,8 @@ # bench (development version) -* `bench::mark()` no longer supports unquote and splice operators. - This fixes inconsistencies in performance results with functions - like `rlang::list2()` (#61). +* `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) 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) }