Skip to content

Commit a2a2e2e

Browse files
Merge pull request #679 from lorenzwalthert/drop-as-character
- Speed improvement in caching (#679).
2 parents 708b1a1 + a0c38cc commit a2a2e2e

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

.github/workflows/benchmarking.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ jobs:
7070
- name: Prepare PR comment
7171
run: |
7272
mkdir -p bench/pr-comment
73-
echo 'Here is how the current PR would change benchmark results:\n' > bench/pr-comment/info.txt
73+
echo "Here is how the current PR would change benchmark results when merged into $GITHUB_BASE_REF:" > bench/pr-comment/info.txt
74+
echo "$GITHUB_EVENT_PULL_REQUEST_HEAD_SHA" >> bench/pr-comment/info.txt
7475
- name: Run benchmarks
7576
run: Rscript -e 'bench::cb_run()'
7677
- name: Show benchmarks

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
- blank lines in function calls and headers are now removed, for the former only
2020
when there are no comments before or after the blank line (#629, #630, #635).
21+
- speed improvement (~10%) when cache is activated because transformers are not
22+
captured as character anymore (#679).
2123

2224
## Minor changes and fixes
2325

R/utils-cache.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ cache_make_key <- function(text, transformers) {
9191
text = hash_standardize(text),
9292
style_guide_name = transformers$style_guide_name,
9393
style_guide_version = transformers$style_guide_version,
94-
style_guide_text = as.character(transformers),
9594
more_specs = as.character(transformers$more_specs) %>%
9695
set_names(names(transformers$more_specs))
9796
)

bench/01-declarations.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ plot_against_base <- function(new_bm,
2727
new_bm <- dplyr::bind_rows(reference, new_bm)
2828
stopifnot(nrow(new_bm) == 2)
2929
diff_in_percent <- round(100 * diff(new_bm$p50) / new_bm$p50[1])
30-
pr_comment <- glue::glue("* {name}: {new_bm$p50[1]} -> {new_bm$p50[2]} ({diff_in_percent}%)\n")
31-
cat(pr_comment, file = "pr-comment/info.txt", append = TRUE)
30+
pr_comment <- glue::glue("* {name}: {round(new_bm$p50[1], 3)} -> {round(new_bm$p50[2], 3)} ({diff_in_percent}%)")
31+
cat(pr_comment, file = "pr-comment/info.txt", sep = "\n", append = TRUE)
3232
}
3333
}
3434
}

0 commit comments

Comments
 (0)