Skip to content

Commit 933e176

Browse files
as any expression is ran twice, must git reset as part of the expression, see ?bench::mark
1 parent 13fa502 commit 933e176

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

touchstone/script.R

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,36 @@ timer <- purrr::partial(touchstone::benchmark_run_ref,
55
refs = refs, n = 10
66
)
77

8+
styler::cache_clear()
9+
810
timer(
911
expr_before_benchmark = c("library(styler)", "cache_deactivate()"),
1012
without_cache = 'style_pkg("touchstone/sources/here", filetype = c("R", "rmd"))'
1113
)
1214

15+
styler::cache_clear()
16+
1317
timer(
1418
expr_before_benchmark = c("library(styler)", "cache_activate()"),
1519
cache_applying = 'style_pkg("touchstone/sources/here", filetype = c("R", "rmd"))'
1620
)
1721

22+
styler::cache_clear()
23+
1824
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"))'
25+
expr_before_benchmark = c(
26+
"library(styler)",
27+
"cache_activate()"
28+
),
29+
cache_recording = c(
30+
"gert::git_reset_hard(repo = 'touchstone/sources/here')",
31+
'style_pkg("touchstone/sources/here", filetype = c("R", "rmd"))'
32+
)
2133
)
2234

35+
styler::cache_clear()
36+
37+
2338

2439
for (benchmark in touchstone::benchmark_ls()) {
2540
timings <- touchstone::benchmark_read(benchmark, refs)
@@ -40,7 +55,7 @@ for (benchmark in touchstone::benchmark_ls()) {
4055

4156
diff_percent <- round(100 * (tbl[refs[2]] - tbl[refs[1]]) / tbl[refs[1]], 1)
4257
cat(
43-
glue::glue("{benchmark}: round(tbl[refs[1]], 2)} -> {round(tbl[refs[2]], 2)} ({diff_percent}%)"),
58+
glue::glue("{benchmark}: {round(tbl[refs[1]], 2)} -> {round(tbl[refs[2]], 2)} ({diff_percent}%)"),
4459
fill = TRUE,
4560
file = "touchstone/pr-comment/info.txt",
4661
append = TRUE

0 commit comments

Comments
 (0)