|
1 |
| -#' Plot benchmarks against master, if benchmarks there exist |
2 |
| -#' |
| 1 | +#' Plot benchmarks against a base branch, if benchmarks there exist |
3 | 2 | #'
|
4 | 3 | #' @param new_bm A new benchmark object.
|
5 | 4 | #' @param new_bm_label The label of the new benchmark used as a title.
|
6 | 5 | #' @param file The file path to write the plot.
|
7 |
| -plot_against_master <- function(new_bm, |
8 |
| - new_bm_label = deparse(substitute(new_bm)), |
9 |
| - file = paste0("plots/", new_bm_label, ".pdf")) { |
| 6 | +plot_against_base <- function(new_bm, |
| 7 | + new_bm_label = deparse(substitute(new_bm)), |
| 8 | + file = paste0("plots/", new_bm_label, ".pdf")) { |
10 | 9 | new_bm <- bench::as_bench_mark(new_bm)
|
11 | 10 | branches <- gert::git_branch_list()
|
12 |
| - master <- branches[branches$name == "master", "commit", drop = TRUE] |
| 11 | + last_commit_base_branch <- branches[branches$name == Sys.getenv("GITHUB_BASE_REF"), "commit", drop = TRUE] |
13 | 12 | bm <- bench::cb_read()
|
14 |
| - hash_is_master <- bm$commit_hash == master |
15 |
| - if (any(hash_is_master) && Sys.getenv("GITHUB_BASE_REF") != "") { |
| 13 | + commit_is_reference <- bm$commit_hash == last_commit_base_branch |
| 14 | + if (any(commit_is_reference) && Sys.getenv("GITHUB_BASE_REF") != "") { |
16 | 15 | # if a pull request
|
17 |
| - reference <- bm[hash_is_master, "benchmarks"][[1]][[1]] |
| 16 | + reference <- bm[commit_is_reference, "benchmarks"][[1]][[1]] |
18 | 17 | reference$expression <- bench:::new_bench_expr(Sys.getenv("GITHUB_BASE_REF"))
|
19 | 18 | new_bm$expression <- bench:::new_bench_expr(Sys.getenv("GITHUB_HEAD_REF"))
|
20 | 19 | new_bm <- rbind(reference, new_bm)
|
|
0 commit comments