diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2022-07-14 09:46:26 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2022-07-14 09:46:26 +0200 |
commit | a41ac4ab2cdfb83ec3aa5f7cda6983f06216fba9 (patch) | |
tree | 560d9148b1695b7337217c3c17e89864e7e12514 /vignettes | |
parent | ab502a6aeacda7c70abe52b8c16e2a15f592a6ed (diff) |
Improve readability of benchmark code shown in vignette
Diffstat (limited to 'vignettes')
-rw-r--r-- | vignettes/web_only/benchmarks.html | 40 | ||||
-rw-r--r-- | vignettes/web_only/benchmarks.rmd | 33 | ||||
-rw-r--r-- | vignettes/web_only/mkin_benchmarks.rda | bin | 1483 -> 1482 bytes |
3 files changed, 44 insertions, 29 deletions
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 { <h1 class="title toc-ignore">Benchmark timings for mkin</h1> <h4 class="author">Johannes Ranke</h4> -<h4 class="date">Last change 1 July 2022 (rebuilt 2022-07-12)</h4> +<h4 class="date">Last change 14 July 2022 (rebuilt 2022-07-14)</h4> </div> <p>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.</p> <p>Every fit is only performed once, so the accuracy of the benchmarks is limited.</p> +<p>The following wrapper function for <code>mmkin</code> is used because the way the error model is specified was changed in mkin version 0.9.49.1.</p> +<pre class="r"><code>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) + } +}</code></pre> <div id="test-cases" class="section level2"> <h2>Test cases</h2> <p>Parent only:</p> @@ -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"]]</code></pre> @@ -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"]]</code></pre> -<pre class="r"><code>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</code></pre> </div> <div id="results" class="section level2"> <h2>Results</h2> @@ -1807,8 +1813,8 @@ rownames(mkin_benchmarks) <- NULL</code></pre> <td align="left">Ryzen 7 1700</td> <td align="left">4.2.1</td> <td align="left">1.1.1</td> -<td align="right">1.767</td> -<td align="right">3.396</td> +<td align="right">1.770</td> +<td align="right">3.377</td> </tr> </tbody> </table> @@ -1969,9 +1975,9 @@ rownames(mkin_benchmarks) <- NULL</code></pre> <td align="left">Ryzen 7 1700</td> <td align="left">4.2.1</td> <td align="left">1.1.1</td> -<td align="right">1.320</td> -<td align="right">5.774</td> -<td align="right">2.575</td> +<td align="right">1.308</td> +<td align="right">5.758</td> +<td align="right">2.558</td> </tr> </tbody> </table> @@ -2180,12 +2186,12 @@ rownames(mkin_benchmarks) <- NULL</code></pre> <td align="left">Ryzen 7 1700</td> <td align="left">4.2.1</td> <td align="left">1.1.1</td> -<td align="right">0.700</td> -<td align="right">1.146</td> -<td align="right">1.334</td> -<td align="right">2.807</td> -<td align="right">1.750</td> -<td align="right">2.593</td> +<td align="right">0.696</td> +<td align="right">1.124</td> +<td align="right">1.321</td> +<td align="right">2.786</td> +<td align="right">1.744</td> +<td align="right">2.566</td> </tr> </tbody> </table> 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 Binary files differindex 49a91664..d507131a 100644 --- a/vignettes/web_only/mkin_benchmarks.rda +++ b/vignettes/web_only/mkin_benchmarks.rda |