From 88e8d7af02db3b026677405840f669abc10ae2a2 Mon Sep 17 00:00:00 2001 From: Lorenz Walthert Date: Wed, 21 Oct 2020 22:14:21 +0200 Subject: [PATCH] add third case, only recording --- bench/02-basic.R | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/bench/02-basic.R b/bench/02-basic.R index 0a2fdca74..a761c4633 100644 --- a/bench/02-basic.R +++ b/bench/02-basic.R @@ -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, @@ -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() @@ -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)