library(magrittr)
touchstone::branch_install()
touchstone::benchmark_run(
small_population = {
set.seed(123)
params <- malariasimulation::get_parameters(
overrides = list(human_population=1e4))
malariasimulation::run_simulation(10000, params)
},
n = 10
)
touchstone::benchmark_run(
large_population = {
set.seed(123)
params <- malariasimulation::get_parameters(
overrides = list(human_population=1e6))
malariasimulation::run_simulation(1000, params)
},
n = 4
)
touchstone::benchmark_analyze()
# Overwrite the plots generated by touchstone with something more sensible.
touchstone::benchmark_ls() %>%
dplyr::reframe(touchstone::benchmark_read(name, branch)) %>%
dplyr::mutate(branch=as.factor(branch), name=as.factor(name)) %>%
dplyr::group_by(name) %>%
dplyr::group_walk(function(data, key) {
ggplot2::ggplot(data, ggplot2::aes(y = branch, x = elapsed, color = branch)) +
ggplot2::geom_boxplot() +
ggplot2::geom_jitter(height = 0.2) +
ggplot2::guides(color="none") +
ggplot2::labs(x="Elapsed time", y="Branch") +
bench::scale_x_bench_time(base = NULL) +
ggplot2::ggtitle(key$name)
fs::path(touchstone::dir_touchstone(), "plots", key$name) %>%
fs::path_ext_set("png") %>%
ggplot2::ggsave(height=3)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.