From a41ac4ab2cdfb83ec3aa5f7cda6983f06216fba9 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 14 Jul 2022 09:46:26 +0200 Subject: Improve readability of benchmark code shown in vignette --- vignettes/web_only/benchmarks.html | 40 +++++++++++++++++++-------------- vignettes/web_only/benchmarks.rmd | 33 +++++++++++++++++---------- vignettes/web_only/mkin_benchmarks.rda | Bin 1483 -> 1482 bytes 3 files changed, 44 insertions(+), 29 deletions(-) (limited to 'vignettes/web_only') diff --git a/vignettes/web_only/benchmarks.html b/vignettes/web_only/benchmarks.html index 4afe49c4..5f81f39f 100644 --- a/vignettes/web_only/benchmarks.html +++ b/vignettes/web_only/benchmarks.html @@ -1599,13 +1599,23 @@ div.tocify {

Benchmark timings for mkin

Johannes Ranke

-

Last change 1 July 2022 (rebuilt 2022-07-12)

+

Last change 14 July 2022 (rebuilt 2022-07-14)

Each system is characterized by the operating system type, the CPU type, the mkin version, and, as in June 2022 the current R version lead to worse performance, the R version. A compiler was available, so if no analytical 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.

+
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)
+  }
+}

Test cases

Parent only:

@@ -1613,6 +1623,7 @@ div.tocify { 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"]] @@ -1658,11 +1669,6 @@ t10 <- system.time(mmkin_bench(list(m_synth_SFO_lin), list(SFO_lin_a), error_model = "obs"))[["elapsed"]] t11 <- system.time(mmkin_bench(list(m_synth_DFOP_par), list(DFOP_par_c), error_model = "obs"))[["elapsed"]] -
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)
-# Hide rownames from kable for results section
-rownames(mkin_benchmarks) <- NULL

Results

@@ -1807,8 +1813,8 @@ rownames(mkin_benchmarks) <- NULL Ryzen 7 1700 4.2.1 1.1.1 -1.767 -3.396 +1.770 +3.377 @@ -1969,9 +1975,9 @@ rownames(mkin_benchmarks) <- NULL Ryzen 7 1700 4.2.1 1.1.1 -1.320 -5.774 -2.575 +1.308 +5.758 +2.558 @@ -2180,12 +2186,12 @@ rownames(mkin_benchmarks) <- NULL Ryzen 7 1700 4.2.1 1.1.1 -0.700 -1.146 -1.334 -2.807 -1.750 -2.593 +0.696 +1.124 +1.321 +2.786 +1.744 +2.566 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) diff --git a/vignettes/web_only/mkin_benchmarks.rda b/vignettes/web_only/mkin_benchmarks.rda index 49a91664..d507131a 100644 Binary files a/vignettes/web_only/mkin_benchmarks.rda and b/vignettes/web_only/mkin_benchmarks.rda differ -- cgit v1.2.1