Benchmarking.Rmd
Comparisons of speed for different Markov Smoking Probabilistic models.
Functions being tested are. Creates list of functions where the name starts with markov. All top level functions should start with this.
function_names <- ls("package:hermes6", pattern = "markov*") function_names #> [1] "markov" #> [2] "markov_expanded" #> [3] "markov_expanded_lapply" #> [4] "markov_expanded_lapply_rcpp" #> [5] "markov_expanded_lapply_vectorise" #> [6] "markov_expanded_parallisesmp_foreach" #> [7] "markov_expanded_parallisesmp_furrr" #> [8] "markov_expanded_parallisesmp_mclapply" #> [9] "markov_expanded_vectorise" #> [10] "markov_expanded_vectorisesmp" #> [11] "markov_rcpp" #> [12] "markov_reduced_dimensions" #> [13] "markov_vectorisetx" #> [14] "markov_vectorisetxsmp"
output <- lapply(function_names, function(func) { func_call <- call(func) print(func_call) out <- system.time(eval(func_call)) print(out) out["elapsed"] }) #> markov() #> user system elapsed #> 8.653 0.056 8.709 #> markov_expanded() #> user system elapsed #> 17.676 0.264 17.942 #> markov_expanded_lapply() #> user system elapsed #> 12.713 0.368 13.082 #> markov_expanded_lapply_rcpp() #> user system elapsed #> 6.621 0.452 7.074 #> markov_expanded_lapply_vectorise() #> user system elapsed #> 11.196 0.464 11.660 #> markov_expanded_parallisesmp_foreach() #> user system elapsed #> 4.969 0.405 9.994 #> markov_expanded_parallisesmp_furrr() #> #> Attaching package: 'purrr' #> The following object is masked from 'package:magrittr': #> #> set_names #> user system elapsed #> 5.733 0.104 5.836 #> markov_expanded_parallisesmp_mclapply() #> user system elapsed #> 10.247 0.696 5.838 #> markov_expanded_vectorise() #> user system elapsed #> 13.784 0.356 14.140 #> markov_expanded_vectorisesmp() #> user system elapsed #> 3.764 0.000 3.764 #> markov_rcpp() #> user system elapsed #> 1.095 0.000 1.095 #> markov_reduced_dimensions() #> user system elapsed #> 4.733 0.000 4.733 #> markov_vectorisetx() #> user system elapsed #> 3.333 0.000 3.333 #> markov_vectorisetxsmp() #> user system elapsed #> 3.558 0.000 3.557 names(output) <- function_names
Benchmarking
output_df <- output %>% unlist(recursive = FALSE) %>% enframe() output_df #> # A tibble: 14 x 2 #> name value #> <chr> <dbl> #> 1 markov.elapsed 8.71 #> 2 markov_expanded.elapsed 17.9 #> 3 markov_expanded_lapply.elapsed 13.1 #> 4 markov_expanded_lapply_rcpp.elapsed 7.07 #> 5 markov_expanded_lapply_vectorise.elapsed 11.7 #> 6 markov_expanded_parallisesmp_foreach.elapsed 9.99 #> 7 markov_expanded_parallisesmp_furrr.elapsed 5.84 #> 8 markov_expanded_parallisesmp_mclapply.elapsed 5.84 #> 9 markov_expanded_vectorise.elapsed 14.1 #> 10 markov_expanded_vectorisesmp.elapsed 3.76 #> 11 markov_rcpp.elapsed 1.09 #> 12 markov_reduced_dimensions.elapsed 4.73 #> 13 markov_vectorisetx.elapsed 3.33 #> 14 markov_vectorisetxsmp.elapsed 3.56