From a41ac4ab2cdfb83ec3aa5f7cda6983f06216fba9 Mon Sep 17 00:00:00 2001
From: Johannes Ranke <jranke@uni-bremen.de>
Date: Thu, 14 Jul 2022 09:46:26 +0200
Subject: Improve readability of benchmark code shown in vignette

---
 vignettes/web_only/benchmarks.rmd | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

(limited to 'vignettes/web_only/benchmarks.rmd')

diff --git a/vignettes/web_only/benchmarks.rmd b/vignettes/web_only/benchmarks.rmd
index 420bef27..9c8c10b7 100644
--- a/vignettes/web_only/benchmarks.rmd
+++ b/vignettes/web_only/benchmarks.rmd
@@ -1,7 +1,7 @@
 ---
 title: "Benchmark timings for mkin"
 author: "Johannes Ranke"
-date: Last change 1 July 2022 (rebuilt `r Sys.Date()`)
+date: Last change 14 July 2022 (rebuilt `r Sys.Date()`)
 output:
   html_document:
     toc: true
@@ -26,6 +26,21 @@ solution was available, compiled ODE models are used.
 
 Every fit is only performed once, so the accuracy of the benchmarks is limited.
 
+The following wrapper function for `mmkin` is used because the way the error
+model is specified was changed in mkin version 0.9.49.1.
+
+```{r}
+if (packageVersion("mkin") > "0.9.48.1") {
+  mmkin_bench <- function(models, datasets, error_model = "const") {
+    mmkin(models, datasets, error_model = error_model, cores = 1, quiet = TRUE)
+  }
+} else {
+  mmkin_bench <- function(models, datasets, error_model = NULL) {
+    mmkin(models, datasets, reweight.method = error_model, cores = 1, quiet = TRUE)
+  }
+}
+```
+
 ```{r include = FALSE}
 cpu_model <- benchmarkme::get_cpu()$model_name
 # Abbreviate CPU identifiers
@@ -53,18 +68,11 @@ load(benchmark_path)
 
 mkin_benchmarks[system_string, c("CPU", "OS", "mkin", "R")] <-
   c(cpu_model, operating_system, mkin_version, R_version)
-
-if (mkin_version > "0.9.48.1") {
-  mmkin_bench <- function(models, datasets, error_model = "const") {
-    mmkin(models, datasets, error_model = error_model, cores = 1, quiet = TRUE)
-  }
-} else {
-  mmkin_bench <- function(models, datasets, error_model = NULL) {
-    mmkin(models, datasets, reweight.method = error_model, cores = 1, quiet = TRUE)
-  }
-}
 ```
 
+
+
+
 ## Test cases
 
 Parent only:
@@ -74,6 +82,7 @@ FOCUS_C <- FOCUS_2006_C
 FOCUS_D <- subset(FOCUS_2006_D, value != 0)
 parent_datasets <- list(FOCUS_C, FOCUS_D)
 
+
 t1 <- system.time(mmkin_bench(c("SFO", "FOMC", "DFOP", "HS"), parent_datasets))[["elapsed"]]
 t2 <- system.time(mmkin_bench(c("SFO", "FOMC", "DFOP", "HS"), parent_datasets,
     error_model = "tc"))[["elapsed"]]
@@ -129,7 +138,7 @@ t11 <- system.time(mmkin_bench(list(m_synth_DFOP_par), list(DFOP_par_c),
     error_model = "obs"))[["elapsed"]]
 ```
 
-```{r results}
+```{r results, include = FALSE}
 mkin_benchmarks[system_string, paste0("t", 1:11)] <-
   c(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11)
 save(mkin_benchmarks, file = benchmark_path)
-- 
cgit v1.2.1

