press() is used to run bench::mark() across a grid of parameters and then press the results together.

The parameters you want to set are given as named arguments and a grid of all possible combinations is automatically created.

The code to setup and benchmark is given by one unnamed expression (often delimited by {).

If replicates are desired a dummy variable can be used, e.g. rep = 1:5 for replicates.

press(..., .grid = NULL)

Arguments

...

If named, parameters to define, if unnamed the expression to run. Only one unnamed expression is permitted.

.grid

A pre-build grid of values to use, typically a data.frame or tibble. This is useful if you only want to use a subset of all possible combinations.

Examples

# Helper function to create a simple data.frame of the specified dimensions create_df <- function(rows, cols) { as.data.frame(setNames( replicate(cols, runif(rows, 1, 1000), simplify = FALSE), rep_len(c("x", letters), cols))) } # Run 4 data sizes across 3 samples with 2 replicates (24 total benchmarks) press( rows = c(1000, 10000), cols = c(10, 100), rep = 1:2, { dat <- create_df(rows, cols) bench::mark( min_time = .05, bracket = dat[dat$x > 500, ], which = dat[which(dat$x > 500), ], subset = subset(dat, x > 500) ) } )
#> Running with: #> rows cols rep
#> 1 1000 10 1
#> 2 10000 10 1
#> 3 1000 100 1
#> 4 10000 100 1
#> 5 1000 10 2
#> 6 10000 10 2
#> 7 1000 100 2
#> 8 10000 100 2
#> Warning: Some expressions had a GC in every iteration; so filtering is disabled.
#> # A tibble: 24 x 17 #> expression rows cols rep min mean median max `itr/sec` #> * <chr> <dbl> <dbl> <int> <bch:tm> <bch:tm> <bch:tm> <bch:tm> <dbl> #> 1 bracket 1000 10 1 193.93µs 212.13µs 201.45µs 421.94µs 4714. #> 2 which 1000 10 1 181.41µs 195.5µs 186.52µs 334.79µs 5115. #> 3 subset 1000 10 1 226.4µs 272.54µs 241.99µs 490.11µs 3669. #> 4 bracket 10000 10 1 917.69µs 986.7µs 945.92µs 1.44ms 1013. #> 5 which 10000 10 1 616.65µs 649.98µs 624.22µs 888.3µs 1539. #> 6 subset 10000 10 1 1.05ms 1.1ms 1.07ms 1.3ms 911. #> 7 bracket 1000 100 1 1.39ms 1.98ms 1.48ms 5.55ms 506. #> 8 which 1000 100 1 1.22ms 1.33ms 1.27ms 1.8ms 751. #> 9 subset 1000 100 1 1.4ms 1.53ms 1.47ms 2.38ms 652. #> 10 bracket 10000 100 1 7.8ms 7.8ms 7.8ms 7.8ms 128. #> # ... with 14 more rows, and 8 more variables: mem_alloc <bch:byt>, n_gc <dbl>, #> # n_itr <int>, total_time <bch:tm>, result <list>, memory <list>, #> # time <list>, gc <list>