Skip to content

Commit

Permalink
add third case, only recording
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzwalthert committed Oct 21, 2020
1 parent c50338f commit 88e8d7a
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions bench/02-basic.R
Expand Up @@ -6,8 +6,6 @@ library(magrittr)
path <- "sources/here"
dir.create("plots")
cache_clear(ask = FALSE)
cache_activate()
cache_info()

marker <- purrr::partial(
bench::mark,
Expand All @@ -17,12 +15,30 @@ marker <- purrr::partial(
memory = TRUE # skip uncached first round
)

# basically applying cache only
# No transformer is ran ever because all code is already compliant.
cache_activate()
cache_info()
with_cache <- marker(
cache_appyling = {
style_pkg(path, filetype = c("R", "rmd"))
}
)

# basically recording cache only
# transformers are always ran on expressions that were not compliant with the
# style guide (some but not all expressions are)
with_cache <- marker(
with_cache = {
cache_recording = {
gert::git_reset_hard(repo = path)
style_pkg(path, filetype = c("R", "rmd"))
}
)

cache_info()

# cache turned off
# recording and applying, transformers always ran on all expressions.
gert::git_reset_hard(repo = path)
cache_deactivate()

Expand All @@ -31,6 +47,8 @@ without_cache <- marker(
style_pkg(path, filetype = c("R", "rmd"))
}
)

# visualize results
latest_bm <- bench::cb_read()$benchmarks[[1]]
split(latest_bm, latest_bm$name) %>%
purrr::imap(plot_against_base)

0 comments on commit 88e8d7a

Please sign in to comment.