Skip to content

Commit 432dc1e

Browse files
Merge pull request #44 from assignUser/issue43-significant-emoji
- Issue43 significant emoji (#44).
2 parents 2a4a6d4 + b7b97dc commit 432dc1e

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

R/analyze.R

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ benchmark_verbalize <- function(benchmark, timings, refs, ci) {
9393
confint <- confint_relative_get(timings, refs, tbl$mean[1], ci = ci)
9494

9595
text <- glue::glue(
96-
"* {benchmark}: {tbl$mean[1]}s -> {tbl$mean[2]}s {confint}"
96+
"* {confint$emoji}{benchmark}: {tbl$mean[1]}s -> {tbl$mean[2]}s {confint$string}"
9797
)
9898
cat(
9999
text,
@@ -108,6 +108,10 @@ set_sign <- function(x) {
108108
}
109109

110110
confint_relative_get <- function(timings, refs, reference, ci) {
111+
no_change <- "&nbsp;&nbsp;:ballot_box_with_check:"
112+
slower <- ":exclamation::snail:"
113+
faster <- "&nbsp;&nbsp;:rocket:"
114+
111115
timings_with_factors <- timings %>%
112116
dplyr::mutate(
113117
block = factor(.data$block), ref = factor(.data$ref, levels = refs)
@@ -116,7 +120,22 @@ confint_relative_get <- function(timings, refs, reference, ci) {
116120
fit <- stats::aov(elapsed ~ ref, data = timings_with_factors)
117121
var <- paste0("ref", refs[2])
118122
confint <- confint(fit, var, level = ci)
119-
paste0("[", paste0(set_sign(round(100 * confint / reference, 2)), collapse = "%, "), "%]")
123+
confint <- round(100 * confint / reference, 2)
124+
emoji <- confint %>%
125+
purrr::when(
126+
all(. < 0) ~ faster,
127+
all(. > 0) ~ slower,
128+
~ no_change
129+
)
130+
131+
list(
132+
string = paste0(
133+
"[",
134+
paste0(set_sign(confint), collapse = "%, "),
135+
"%]"
136+
),
137+
emoji = emoji
138+
)
120139
}
121140

122141

@@ -130,4 +149,4 @@ benchmark_plot <- function(benchmark, timings) {
130149
fs::path(dir_touchstone(), "plots", benchmark) %>%
131150
fs::path_ext_set("png") %>%
132151
ggplot2::ggsave()
133-
}
152+
}

R/core.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ benchmark_run_iteration <- function(expr_before_benchmark,
4141

4242
#' Run a benchmark for git refs
4343
#'
44-
#' @param ... Named epression or named character vector of length one with code to benchmark, will
44+
#' @param ... Named expression or named character vector of length one with code to benchmark, will
4545
#' be evaluated with [exprs_eval()].
4646
#' @param refs Character vector with branch names to benchmark. The package
4747
#' must be built for each benchmarked branch beforehand with [refs_install()].

man/benchmark_run_ref.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-analyze.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ test_that("can analyze results", {
1111
block = 1
1212
))
1313
mockery::stub(
14-
benchmark_verbalize, "confint_relative_get", "[x.xx%, y.yy%]",
14+
benchmark_verbalize,
15+
"confint_relative_get",
16+
list(string = "[x.xx%, y.yy%]", emoji = ":rocket:"),
1517
depth = 2
1618
)
1719
benchmarks_analyze(branches)
@@ -49,7 +51,9 @@ test_that("can analyze results", {
4951
))
5052

5153
mockery::stub(
52-
benchmark_verbalize, "confint_relative_get", "[x.xx%, y.yy%]",
54+
benchmark_verbalize,
55+
"confint_relative_get",
56+
list(string = "[x.xx%, y.yy%]", emoji = ":rocket:"),
5357
depth = 2
5458
)
5559
fs::file_delete(fs::path(dir_touchstone(), "records", "xx1", branches[1]))

0 commit comments

Comments
 (0)