Skip to content

Commit 8a4a2e1

Browse files
factor out of loop
1 parent 1f59b3b commit 8a4a2e1

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

touchstone/script.R

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
# touchstone:::touchstone_clear() # deletes itself and sources
22
refs <- c(Sys.getenv("GITHUB_BASE_REF", "touchstone"), Sys.getenv("GITHUB_HEAD_REF", "touchstone"))
3-
exprs_to_benchmark <- list(
3+
4+
timer <- purrr::partial(touchstone::benchmark_run_ref,
5+
refs = refs, n = 10
6+
)
7+
8+
timer(
9+
expr_before_benchmark = c("library(styler)", "cache_deactivate()"),
10+
without_cache = 'style_pkg("touchstone/sources/here", filetype = c("R", "rmd"))'
11+
)
12+
13+
timer(
14+
expr_before_benchmark = c("library(styler)", "cache_activate()"),
415
cache_applying = 'style_pkg("touchstone/sources/here", filetype = c("R", "rmd"))'
516
)
6-
for (benchmark in names(exprs_to_benchmark)) {
7-
timings <- touchstone::benchmark_run_ref(
8-
refs,
9-
expr_before_benchmark = c("library(styler)", "cache_deactivate()"),
10-
!!!exprs_to_benchmark[[benchmark]],
11-
n = 10
12-
)
1317

18+
timer(
19+
expr_before_benchmark = c("library(styler)", "gert::git_reset_hard(repo = 'touchstone/sources/here')", "cache_activate()"),
20+
cache_recording = 'style_pkg("touchstone/sources/here", filetype = c("R", "rmd"))'
21+
)
22+
23+
24+
for (benchmark in touchstone::benchmark_ls()) {
1425
timings <- touchstone::benchmark_read(benchmark, refs[1])
1526

1627
library(ggplot2)
@@ -30,6 +41,7 @@ for (benchmark in names(exprs_to_benchmark)) {
3041
diff_percent <- round(100 * (tbl[refs[2]] - tbl[refs[1]]) / tbl[refs[1]], 1)
3142
cat(
3243
glue::glue("{benchmark}: round(tbl[refs[1]], 2)} -> {round(tbl[refs[2]], 2)} ({diff_percent}%)"),
44+
fill = TRUE,
3345
file = "touchstone/pr-comment/info.txt",
3446
append = TRUE
3547
)

0 commit comments

Comments
 (0)