Benchmark a list of quoted expressions. Each expression will always run at least twice, once to measure the memory allocation and store results and one or more times to measure timing.
mark(..., min_time = 0.5, iterations = NULL, min_iterations = 1, max_iterations = 10000, check = TRUE, filter_gc = TRUE, relative = FALSE, env = parent.frame())
Expressions to benchmark, if named the
The minimum number of seconds to run each expression, set to
Each expression will be evaluated a minimum of
Each expression will be evaluated a maximum of
Check if results are consistent. If
The environment which to evaluate the expressions
A tibble with the additional summary columns. The following summary columns are computed
bench_time The minimum execution time.
bench_time The arithmetic mean of execution time
bench_time The sample median of execution time.
bench_time The maximum execution time.
bench_bytes Total amount of memory allocated by running the expression.
integer The estimated number of executions performed per second.
integer Total number of iterations after filtering
garbage collections (if
filter_gc == TRUE).
integer Total number of garbage collections performed over all runs.
press() to run benchmarks across a grid of parameters.
dat <- data.frame(x = runif(100, 1, 1000), y=runif(10, 1, 1000)) mark( min_time = .1, dat[dat$x > 500, ], dat[which(dat$x > 500), ], subset(dat, x > 500))#> # A tibble: 3 x 14 #> expression min mean median max `itr/sec` mem_alloc n_gc n_itr #> <chr> <bch:t> <bch:t> <bch:> <bch:> <dbl> <bch:byt> <dbl> <int> #> 1 dat[dat$x > 50… 32.4µs 42.7µs 39.9µs 577µs 23422. 4.49KB 2 2141 #> 2 dat[which(dat$… 32.1µs 39.1µs 37.2µs 163µs 25571. 3.85KB 1 2376 #> 3 subset(dat, x … 46.7µs 54.1µs 51.9µs 206µs 18478. 5.78KB 2 1591 #> # ... with 5 more variables: total_time <bch:tm>, result <list>, memory <list>, #> # time <list>, gc <list>