This function runs a benchmark across multiple approaches to Markov model simulation. This includes multiple approaches using Rcpp and different strategies for parallisation. Unless otherwise stated the default settings for SpeedyMarkov are used (which are to maximise the use of Rcpp). Note: mclapply uses mutlicore parallisation which is only available on Mac and Linux. future and furrr default to multicore parallisation but this will again not be used on Windows or in an interactive Rstudio session. This may impact benchmark performance.).

This function relies on suggested packages and so requires the installation of the following packages:

  • microbenchmark

  • furrr

benchmark_markov(
  markov_model = NULL,
  reference = NULL,
  duration = NULL,
  samples = NULL,
  times = 1
)

Arguments

markov_model

A list of functions that define a markov model across multiple interventions. See example_two_state_markov for the correct format.

reference

Function, the reference model to compare the SpeedyMarkov approaches to. An example of a reference model is reference_two_state_markov.

duration

Numeric, how many long to run the model for.

samples

Numeric, defaults to 1. The number of markov model samples to use.

times

Numeric, the number of times to repeat the benchmark. Defaults to once. Repeating the benchmark can help control for stochastic effects.

Value

Returns a microbenchmark data.frame of benchmarking results

Examples

if (FALSE) { # Run a benchmark across approaches for a small number of samples results <- benchmark_markov(markov_model = example_two_state_markov, reference = reference_two_state_markov, duration = 100, samples = 1000, times = 10) results ggplot2::autoplot(results) }