Skip to content

Commit 98ca368

Browse files
fix plot
1 parent 2c7a5df commit 98ca368

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

bench/01-declarations.R

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,30 @@ plot_against_base <- function(new_bm,
77
new_bm_label = deparse(substitute(new_bm)),
88
file = paste0("plots/", new_bm_label, ".pdf")) {
99
new_bm <- bench::as_bench_mark(new_bm)
10+
name <- unique(new_bm$name)
11+
stopifnot(length(name) == 1)
1012
branches <- gert::git_branch_list()
1113
last_commit_base_branch <- branches[branches$name == Sys.getenv("GITHUB_BASE_REF"), "commit", drop = TRUE]
1214
bm <- bench::cb_read()
1315
commit_is_reference <- bm$commit_hash == last_commit_base_branch
1416
if (any(commit_is_reference) && Sys.getenv("GITHUB_BASE_REF") != "") {
1517
# if a pull request
16-
reference <- bm[commit_is_reference, "benchmarks"][[1]][[1]]
18+
reference <- bm[commit_is_reference, "benchmarks"][[1]][[1]] %>%
19+
dplyr::filter(.data$name %in% !!name)
1720
reference$expression <- bench:::new_bench_expr(Sys.getenv("GITHUB_BASE_REF"))
1821
new_bm$expression <- bench:::new_bench_expr(Sys.getenv("GITHUB_HEAD_REF"))
19-
new_bm <- rbind(reference, new_bm)
22+
new_bm <- dplyr::bind_rows(reference, new_bm)
23+
new_bm$branch <- factor(new_bm$expression)
2024
}
2125
plot <- ggplot2::ggplot(new_bm) +
2226
ggplot2::geom_boxplot(ggplot2::aes(
23-
x = name, ymin = p0,
27+
x = branch, ymin = p0,
2428
ymax = p100, lower = p25,
2529
middle = p50, upper = p75
2630
),
2731
stat = "identity"
28-
)
32+
) +
33+
ggplot2::ggtitle(name)
2934

3035
ggplot2::ggsave(file, plot)
3136
}

0 commit comments

Comments
 (0)