Run a benchmark for git branches

benchmark_run(
  expr_before_benchmark = {
 },
  ...,
  branches = c(branch_get_or_fail("GITHUB_BASE_REF"),
    branch_get_or_fail("GITHUB_HEAD_REF")),
  n = 100,
  path_pkg = "."
)

Arguments

expr_before_benchmark

Expression to run before the benchmark is ran, will be captured with rlang::enexpr(). So you can use quasiquotation.

...

Named expression of length one with code to benchmark, will be captured with rlang::enexprs(). So you can use quasiquotation.

branches

Character vector with branch names to benchmark. The package must be built for each benchmarked branch beforehand with branch_install(). The base branch is the target branch of the pull request in a workflow run, the head branch is the source branch of the pull request in a workflow run.

n

Number of times benchmarks should be run for each branch. The more iterations you run, the more narrow your confidence interval will be and the smaller the differences you will detect. See also vignette("inference"). To simplify interactive experimentation with benchmark_run(), n will be overridden in interactive usage after the user calls activate(..., n = 1).

path_pkg

The path to the package to benchmark. Will be used to temporarily checkout the branch during benchmarking.

Value

All timings in a tibble.

Details

Runs the following loop n times:

  • removes all touchstone libraries from the library path, adding the one corresponding to branch.

  • runs setup code exp_before_branch.

  • benchmarks expr_to_benchmark and writes them to disk.

Caution

This function will perform various git operations that affect the state of the directory it is ran in, in particular different branches will be checked out. Ensure a clean git working directory before invocation.