Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not for merge - benchmark summary(<epichains_tree>) vs simulate_summary() #212

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions benchmarks.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#' Benchmark of two approaches for obtaining chain summaries
#' 1. Simulate chains with `simulate_chains()` then run `summary()` on the
#' output to obtain an `<epichains_summary>` object OR
#' 2. Run `simualte_summary()` directly with the same parameters as
#' `simulate_chains()`

#' Load libraries
devtools::load_all()
library("bench")

# Shared arguments
shared_args <- list(
index_cases = 10,
statistic = "size",
offspring_dist = rnbinom,
stat_max = 1000,
mu = 2,
size = 0.2
)

#' Benchmark
summary_benchmarks <- bench::mark(
sim_chains = {
set.seed(32)
out <- do.call(
simulate_chains,
shared_args
)
summary(out)
},
sim_summary = {
set.seed(32)
do.call(
simulate_summary,
shared_args
)
}
)

bnmark_plt <- plot(bnmarks)

ggplot2::ggsave(
file.path("summary_benchmarks.png"),
bnmark_plt
)
Binary file added summary_benchmarks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading