diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2020-05-13 16:20:23 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2020-05-13 16:20:23 +0200 |
commit | 218a9c55bd80fb708b15fa7196422f759bfe4b27 (patch) | |
tree | ad4b2aa4b561b3118d1ca8ee5e6b34fbd2dfcfe8 /vignettes/web_only | |
parent | 36bc31c52cbe4b686f5562e21ee110380481dff8 (diff) |
Further formatting improvement of benchmark vignette
Also, use .rmd extension instead of .Rmd for vignettes.
Diffstat (limited to 'vignettes/web_only')
-rw-r--r-- | vignettes/web_only/FOCUS_Z.rmd (renamed from vignettes/web_only/FOCUS_Z.Rmd) | 0 | ||||
-rw-r--r-- | vignettes/web_only/NAFTA_examples.rmd (renamed from vignettes/web_only/NAFTA_examples.Rmd) | 0 | ||||
-rw-r--r-- | vignettes/web_only/benchmarks.html | 136 | ||||
-rw-r--r-- | vignettes/web_only/benchmarks.rmd (renamed from vignettes/web_only/benchmarks.Rmd) | 39 | ||||
-rw-r--r-- | vignettes/web_only/compiled_models.rmd (renamed from vignettes/web_only/compiled_models.Rmd) | 282 | ||||
-rw-r--r-- | vignettes/web_only/mkin_benchmarks.rda | bin | 854 -> 854 bytes |
6 files changed, 220 insertions, 237 deletions
diff --git a/vignettes/web_only/FOCUS_Z.Rmd b/vignettes/web_only/FOCUS_Z.rmd index 2da7fde7..2da7fde7 100644 --- a/vignettes/web_only/FOCUS_Z.Rmd +++ b/vignettes/web_only/FOCUS_Z.rmd diff --git a/vignettes/web_only/NAFTA_examples.Rmd b/vignettes/web_only/NAFTA_examples.rmd index 26a9240a..26a9240a 100644 --- a/vignettes/web_only/NAFTA_examples.Rmd +++ b/vignettes/web_only/NAFTA_examples.rmd diff --git a/vignettes/web_only/benchmarks.html b/vignettes/web_only/benchmarks.html index 821399e4..043b777f 100644 --- a/vignettes/web_only/benchmarks.html +++ b/vignettes/web_only/benchmarks.html @@ -11,7 +11,7 @@ <meta name="author" content="Johannes Ranke" /> -<meta name="date" content="2020-05-12" /> +<meta name="date" content="2020-05-13" /> <title>Benchmark timings for mkin</title> @@ -1583,29 +1583,12 @@ div.tocify { <h1 class="title toc-ignore">Benchmark timings for mkin</h1> <h4 class="author">Johannes Ranke</h4> -<h4 class="date">2020-05-12</h4> +<h4 class="date">2020-05-13</h4> </div> -<p>Each system is characterized by its CPU type, the operating system type and the mkin version. Currently only values for one system are available.</p> -<pre class="r"><code>cpu_model <- benchmarkme::get_cpu()$model_name -operating_system <- Sys.info()[["sysname"]] -mkin_version <- as.character(packageVersion("mkin")) -system_string <- paste0(operating_system, ", ", cpu_model, ", mkin version ", mkin_version) -load("~/git/mkin/vignettes/web_only/mkin_benchmarks.rda") -mkin_benchmarks[system_string, c("CPU", "OS", "mkin")] <- - c(cpu_model, operating_system, mkin_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) - } -}</code></pre> +<p>Each system is characterized by its CPU type, the operating system type and the mkin version. Currently only values for one system are available. A compiler was available, so if no analytical solution was available, compiled ODE models are used.</p> <div id="test-cases" class="section level2"> <h2>Test cases</h2> <p>Parent only:</p> @@ -1619,17 +1602,14 @@ t2 <- system.time(mmkin_bench(c("SFO", "FOMC", "DFOP <p>One metabolite:</p> <pre class="r"><code>SFO_SFO <- mkinmod( parent = mkinsub("SFO", "m1"), - m1 = mkinsub("SFO"))</code></pre> -<pre><code>## Successfully compiled differential equation model from auto-generated C code.</code></pre> -<pre class="r"><code>FOMC_SFO <- mkinmod( + m1 = mkinsub("SFO")) +FOMC_SFO <- mkinmod( parent = mkinsub("FOMC", "m1"), - m1 = mkinsub("SFO"))</code></pre> -<pre><code>## Successfully compiled differential equation model from auto-generated C code.</code></pre> -<pre class="r"><code>DFOP_SFO <- mkinmod( + m1 = mkinsub("SFO")) +DFOP_SFO <- mkinmod( parent = mkinsub("FOMC", "m1"), - m1 = mkinsub("SFO"))</code></pre> -<pre><code>## Successfully compiled differential equation model from auto-generated C code.</code></pre> -<pre class="r"><code>t3 <- system.time(mmkin_bench(list(SFO_SFO, FOMC_SFO, DFOP_SFO), list(FOCUS_D)))[["elapsed"]] + m1 = mkinsub("SFO")) +t3 <- system.time(mmkin_bench(list(SFO_SFO, FOMC_SFO, DFOP_SFO), list(FOCUS_D)))[["elapsed"]] t4 <- system.time(mmkin_bench(list(SFO_SFO, FOMC_SFO, DFOP_SFO), list(FOCUS_D), error_model = "tc"))[["elapsed"]] t5 <- system.time(mmkin_bench(list(SFO_SFO, FOMC_SFO, DFOP_SFO), list(FOCUS_D), @@ -1667,127 +1647,123 @@ save(mkin_benchmarks, file = "~/git/mkin/vignettes/web_only/mkin_benchmarks </div> <div id="results" class="section level2"> <h2>Results</h2> -<p>Currently, we only have benchmark information on one system, therefore only the mkin version is shown with the results below. Timings are in seconds, shorter is better.</p> -<pre class="r"><code>rownames(mkin_benchmarks) <- as.character(mkin_benchmarks$mkin)</code></pre> +<p>Currently, we only have benchmark information on one system, therefore only the mkin version is shown with the results below. Timings are in seconds, shorter is better. All results were obtained by serial, i.e. not using multiple computing cores.</p> <p>Benchmarks for all available error models are shown.</p> <div id="parent-only" class="section level3"> <h3>Parent only</h3> -<p>Constant variance and two-component error model:</p> -<pre class="r"><code>kable(mkin_benchmarks[, c("t1", "t2")])</code></pre> +<p>Constant variance (t1) and two-component error model (t2) for four models fitted to two datasets, i.e. eight fits for each test.</p> <table> <thead> <tr class="header"> -<th></th> -<th align="right">t1</th> -<th align="right">t2</th> +<th align="left">mkin version</th> +<th align="right">t1 [s]</th> +<th align="right">t2 [s]</th> </tr> </thead> <tbody> <tr class="odd"> -<td>0.9.48.1</td> +<td align="left">0.9.48.1</td> <td align="right">3.610</td> <td align="right">11.019</td> </tr> <tr class="even"> -<td>0.9.49.1</td> +<td align="left">0.9.49.1</td> <td align="right">8.184</td> <td align="right">22.889</td> </tr> <tr class="odd"> -<td>0.9.49.2</td> +<td align="left">0.9.49.2</td> <td align="right">7.064</td> <td align="right">12.558</td> </tr> <tr class="even"> -<td>0.9.49.3</td> +<td align="left">0.9.49.3</td> <td align="right">7.296</td> <td align="right">21.239</td> </tr> <tr class="odd"> -<td>0.9.49.4</td> +<td align="left">0.9.49.4</td> <td align="right">5.936</td> <td align="right">20.545</td> </tr> <tr class="even"> -<td>0.9.50.2</td> -<td align="right">1.559</td> -<td align="right">3.929</td> +<td align="left">0.9.50.2</td> +<td align="right">1.547</td> +<td align="right">3.928</td> </tr> </tbody> </table> </div> <div id="one-metabolite" class="section level3"> <h3>One metabolite</h3> -<p>Constant variance, variance by variable and two-component error model:</p> -<pre class="r"><code>kable(mkin_benchmarks[, c("t3", "t4", "t5")])</code></pre> +<p>Constant variance (t3), two-component error model (t4), and variance by variable (t5) for three models fitted to one dataset, i.e. three fits for each test.</p> <table> <thead> <tr class="header"> -<th></th> -<th align="right">t3</th> -<th align="right">t4</th> -<th align="right">t5</th> +<th align="left">mkin version</th> +<th align="right">t3 [s]</th> +<th align="right">t4 [s]</th> +<th align="right">t5 [s]</th> </tr> </thead> <tbody> <tr class="odd"> -<td>0.9.48.1</td> +<td align="left">0.9.48.1</td> <td align="right">3.764</td> <td align="right">14.347</td> <td align="right">9.495</td> </tr> <tr class="even"> -<td>0.9.49.1</td> +<td align="left">0.9.49.1</td> <td align="right">4.649</td> <td align="right">13.789</td> <td align="right">6.395</td> </tr> <tr class="odd"> -<td>0.9.49.2</td> +<td align="left">0.9.49.2</td> <td align="right">4.786</td> <td align="right">8.461</td> <td align="right">5.675</td> </tr> <tr class="even"> -<td>0.9.49.3</td> +<td align="left">0.9.49.3</td> <td align="right">4.510</td> <td align="right">13.805</td> <td align="right">7.386</td> </tr> <tr class="odd"> -<td>0.9.49.4</td> +<td align="left">0.9.49.4</td> <td align="right">4.446</td> <td align="right">15.335</td> <td align="right">6.002</td> </tr> <tr class="even"> -<td>0.9.50.2</td> -<td align="right">1.352</td> -<td align="right">6.110</td> -<td align="right">2.841</td> +<td align="left">0.9.50.2</td> +<td align="right">1.371</td> +<td align="right">6.154</td> +<td align="right">2.720</td> </tr> </tbody> </table> </div> <div id="two-metabolites" class="section level3"> <h3>Two metabolites</h3> -<p>Two different datasets, for each constant variance, variance by variable and two-component error model are shown:</p> -<pre class="r"><code>kable(mkin_benchmarks[, paste0("t", 6:11)])</code></pre> +<p>Constant variance (t6 and t7), two-component error model (t8 and t9), and variance by variable (t10 and t11) for one model fitted to one dataset, i.e. one fit for each test.</p> <table> <thead> <tr class="header"> -<th></th> -<th align="right">t6</th> -<th align="right">t7</th> -<th align="right">t8</th> -<th align="right">t9</th> -<th align="right">t10</th> -<th align="right">t11</th> +<th align="left">mkin version</th> +<th align="right">t6 [s]</th> +<th align="right">t7 [s]</th> +<th align="right">t8 [s]</th> +<th align="right">t9 [s]</th> +<th align="right">t10 [s]</th> +<th align="right">t11 [s]</th> </tr> </thead> <tbody> <tr class="odd"> -<td>0.9.48.1</td> +<td align="left">0.9.48.1</td> <td align="right">2.623</td> <td align="right">4.587</td> <td align="right">7.525</td> @@ -1796,7 +1772,7 @@ save(mkin_benchmarks, file = "~/git/mkin/vignettes/web_only/mkin_benchmarks <td align="right">31.267</td> </tr> <tr class="even"> -<td>0.9.49.1</td> +<td align="left">0.9.49.1</td> <td align="right">2.542</td> <td align="right">4.128</td> <td align="right">4.632</td> @@ -1805,7 +1781,7 @@ save(mkin_benchmarks, file = "~/git/mkin/vignettes/web_only/mkin_benchmarks <td align="right">5.636</td> </tr> <tr class="odd"> -<td>0.9.49.2</td> +<td align="left">0.9.49.2</td> <td align="right">2.723</td> <td align="right">4.478</td> <td align="right">4.862</td> @@ -1814,7 +1790,7 @@ save(mkin_benchmarks, file = "~/git/mkin/vignettes/web_only/mkin_benchmarks <td align="right">5.574</td> </tr> <tr class="even"> -<td>0.9.49.3</td> +<td align="left">0.9.49.3</td> <td align="right">2.643</td> <td align="right">4.374</td> <td align="right">7.020</td> @@ -1823,7 +1799,7 @@ save(mkin_benchmarks, file = "~/git/mkin/vignettes/web_only/mkin_benchmarks <td align="right">7.365</td> </tr> <tr class="odd"> -<td>0.9.49.4</td> +<td align="left">0.9.49.4</td> <td align="right">2.635</td> <td align="right">4.259</td> <td align="right">4.737</td> @@ -1832,13 +1808,13 @@ save(mkin_benchmarks, file = "~/git/mkin/vignettes/web_only/mkin_benchmarks <td align="right">5.626</td> </tr> <tr class="even"> -<td>0.9.50.2</td> -<td align="right">0.759</td> -<td align="right">1.204</td> -<td align="right">1.275</td> -<td align="right">2.837</td> -<td align="right">2.026</td> -<td align="right">2.976</td> +<td align="left">0.9.50.2</td> +<td align="right">0.742</td> +<td align="right">1.203</td> +<td align="right">1.282</td> +<td align="right">2.845</td> +<td align="right">2.037</td> +<td align="right">2.987</td> </tr> </tbody> </table> diff --git a/vignettes/web_only/benchmarks.Rmd b/vignettes/web_only/benchmarks.rmd index 990c2fee..7ae12451 100644 --- a/vignettes/web_only/benchmarks.Rmd +++ b/vignettes/web_only/benchmarks.rmd @@ -20,9 +20,11 @@ library("mkin") ``` Each system is characterized by its CPU type, the operating system type and the -mkin version. Currently only values for one system are available. +mkin version. Currently only values for one system are available. A compiler +was available, so if no analytical solution was available, compiled ODE models are +used. -```{r} +```{r include = FALSE} cpu_model <- benchmarkme::get_cpu()$model_name operating_system <- Sys.info()[["sysname"]] mkin_version <- as.character(packageVersion("mkin")) @@ -58,7 +60,7 @@ t2 <- system.time(mmkin_bench(c("SFO", "FOMC", "DFOP", "HS"), parent_datasets, One metabolite: -```{r one_metabolite} +```{r one_metabolite, message = FALSE} SFO_SFO <- mkinmod( parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO")) @@ -77,7 +79,7 @@ t5 <- system.time(mmkin_bench(list(SFO_SFO, FOMC_SFO, DFOP_SFO), list(FOCUS_D), Two metabolites, synthetic data: -```{r two_metabolites} +```{r two_metabolites, message = FALSE} m_synth_SFO_lin <- mkinmod(parent = mkinsub("SFO", "M1"), M1 = mkinsub("SFO", "M2"), M2 = mkinsub("SFO"), @@ -116,9 +118,11 @@ save(mkin_benchmarks, file = "~/git/mkin/vignettes/web_only/mkin_benchmarks.rda" Currently, we only have benchmark information on one system, therefore only the mkin version is shown with the results below. Timings are in seconds, shorter is better. +All results were obtained by serial, i.e. not using multiple computing cores. -```{r} -rownames(mkin_benchmarks) <- as.character(mkin_benchmarks$mkin) +```{r, include = FALSE} +dimnames(mkin_benchmarks) <- list(as.character(mkin_benchmarks$mkin), + c("CPU", "OS", "mkin version", paste0("t", 1:11, " [s]"))) ``` @@ -126,25 +130,28 @@ Benchmarks for all available error models are shown. ### Parent only -Constant variance and two-component error model: +Constant variance (t1) and two-component error model (t2) for four models +fitted to two datasets, i.e. eight fits for each test. -```{r} -kable(mkin_benchmarks[, c("t1", "t2")]) +```{r, echo = FALSE} +kable(mkin_benchmarks[, 4:5], rownames = "mkin version") ``` ### One metabolite -Constant variance, variance by variable and two-component error model: +Constant variance (t3), two-component error model (t4), and variance by variable (t5) +for three models fitted to one dataset, i.e. three fits for each test. -```{r} -kable(mkin_benchmarks[, c("t3", "t4", "t5")]) +```{r, echo = FALSE} +kable(mkin_benchmarks[, 6:8], rownames = "mkin version") ``` ### Two metabolites -Two different datasets, for each constant variance, variance by variable and -two-component error model are shown: +Constant variance (t6 and t7), two-component error model (t8 and t9), and +variance by variable (t10 and t11) for one model fitted to one dataset, i.e. +one fit for each test. -```{r} -kable(mkin_benchmarks[, paste0("t", 6:11)]) +```{r, echo = FALSE} +kable(mkin_benchmarks[, 9:14], rownames = "mkin version") ``` diff --git a/vignettes/web_only/compiled_models.Rmd b/vignettes/web_only/compiled_models.rmd index f99ea808..0b8c617a 100644 --- a/vignettes/web_only/compiled_models.Rmd +++ b/vignettes/web_only/compiled_models.rmd @@ -1,141 +1,141 @@ ----
-title: "Performance benefit by using compiled model definitions in mkin"
-author: "Johannes Ranke"
-output:
- html_document:
- toc: true
- toc_float: true
- code_folding: show
- fig_retina: null
-date: "`r Sys.Date()`"
-vignette: >
- %\VignetteEngine{knitr::rmarkdown}
- %\VignetteEncoding{UTF-8}
----
-
-```{r, include = FALSE}
-library(knitr)
-opts_chunk$set(tidy = FALSE, cache = FALSE)
-```
-
-## How to benefit from compiled models
-
-When using an mkin version equal to or greater than 0.9-36 and a C compiler is
-available, you will see a message that the model is being compiled from
-autogenerated C code when defining a model using mkinmod. Starting from
-version 0.9.49.9, the `mkinmod()` function checks for presence of a compiler
-using
-
-```{r check_gcc, eval = FALSE}
-pkgbuild::has_compiler()
-```
-
-In previous versions, it used `Sys.which("gcc")` for this check.
-
-On Linux, you need to have the essential build tools like make and gcc or clang
-installed. On Debian based linux distributions, these will be pulled in by installing
-the build-essential package.
-
-On MacOS, which I do not use personally, I have had reports that a compiler is
-available by default.
-
-On Windows, you need to install Rtools and have the path to its bin directory
-in your PATH variable. You do not need to modify the PATH variable when
-installing Rtools. Instead, I would recommend to put the line
-
-```{r Rprofile, eval = FALSE}
-Sys.setenv(PATH = paste("C:/Rtools/bin", Sys.getenv("PATH"), sep=";"))
-```
-into your .Rprofile startup file. This is just a text file with some R
-code that is executed when your R session starts. It has to be named .Rprofile
-and has to be located in your home directory, which will generally be your
-Documents folder. You can check the location of the home directory used by R by
-issuing
-
-```{r HOME, eval = FALSE}
-Sys.getenv("HOME")
-```
-
-## Comparison with other solution methods
-
-First, we build a simple degradation model for a parent compound with one metabolite,
-and we remove zero values from the dataset.
-
-```{r create_SFO_SFO}
-library("mkin", quietly = TRUE)
-SFO_SFO <- mkinmod(
- parent = mkinsub("SFO", "m1"),
- m1 = mkinsub("SFO"))
-FOCUS_D <- subset(FOCUS_2006_D, value != 0)
-```
-
-We can compare the performance of the Eigenvalue based solution against the
-compiled version and the R implementation of the differential equations using
-the benchmark package. In the output of below code, the warnings about zero
-being removed from the FOCUS D dataset are suppressed. Since mkin version
-0.9.49.11, an analytical solution is also implemented, which is included
-in the tests below.
-
-```{r benchmark_SFO_SFO, fig.height = 3, message = FALSE, warning = FALSE}
-if (require(rbenchmark)) {
- b.1 <- benchmark(
- "deSolve, not compiled" = mkinfit(SFO_SFO, FOCUS_D,
- solution_type = "deSolve",
- use_compiled = FALSE, quiet = TRUE),
- "Eigenvalue based" = mkinfit(SFO_SFO, FOCUS_D,
- solution_type = "eigen", quiet = TRUE),
- "deSolve, compiled" = mkinfit(SFO_SFO, FOCUS_D,
- solution_type = "deSolve", quiet = TRUE),
- "analytical" = mkinfit(SFO_SFO, FOCUS_D,
- solution_type = "analytical",
- use_compiled = FALSE, quiet = TRUE),
- replications = 1, order = "relative",
- columns = c("test", "replications", "relative", "elapsed"))
- print(b.1)
-} else {
- print("R package rbenchmark is not available")
-}
-```
-
-We see that using the compiled model is by more than a factor of 10 faster
-than using deSolve without compiled code.
-
-## Model without analytical solution
-
-This evaluation is also taken from the example section of mkinfit. No analytical
-solution is available for this system, and now Eigenvalue based solution
-is possible, so only deSolve using with or without compiled code is
-available.
-
-```{r benchmark_FOMC_SFO, fig.height = 3, warning = FALSE}
-if (require(rbenchmark)) {
- FOMC_SFO <- mkinmod(
- parent = mkinsub("FOMC", "m1"),
- m1 = mkinsub( "SFO"))
-
- b.2 <- benchmark(
- "deSolve, not compiled" = mkinfit(FOMC_SFO, FOCUS_D,
- use_compiled = FALSE, quiet = TRUE),
- "deSolve, compiled" = mkinfit(FOMC_SFO, FOCUS_D, quiet = TRUE),
- replications = 1, order = "relative",
- columns = c("test", "replications", "relative", "elapsed"))
- print(b.2)
- factor_FOMC_SFO <- round(b.2["1", "relative"])
-} else {
- factor_FOMC_SFO <- NA
- print("R package benchmark is not available")
-}
-```
-
-Here we get a performance benefit of a factor of
-`r factor_FOMC_SFO`
-using the version of the differential equation model compiled from C code!
-
-This vignette was built with mkin `r utils::packageVersion("mkin")` on
-
-```{r sessionInfo, echo = FALSE}
-cat(utils::capture.output(utils::sessionInfo())[1:3], sep = "\n")
-if(!inherits(try(cpuinfo <- readLines("/proc/cpuinfo")), "try-error")) {
- cat(gsub("model name\t: ", "CPU model: ", cpuinfo[grep("model name", cpuinfo)[1]]))
-}
-```
+--- +title: "Performance benefit by using compiled model definitions in mkin" +author: "Johannes Ranke" +output: + html_document: + toc: true + toc_float: true + code_folding: show + fig_retina: null +date: "`r Sys.Date()`" +vignette: > + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +library(knitr) +opts_chunk$set(tidy = FALSE, cache = FALSE) +``` + +## How to benefit from compiled models + +When using an mkin version equal to or greater than 0.9-36 and a C compiler is +available, you will see a message that the model is being compiled from +autogenerated C code when defining a model using mkinmod. Starting from +version 0.9.49.9, the `mkinmod()` function checks for presence of a compiler +using + +```{r check_gcc, eval = FALSE} +pkgbuild::has_compiler() +``` + +In previous versions, it used `Sys.which("gcc")` for this check. + +On Linux, you need to have the essential build tools like make and gcc or clang +installed. On Debian based linux distributions, these will be pulled in by installing +the build-essential package. + +On MacOS, which I do not use personally, I have had reports that a compiler is +available by default. + +On Windows, you need to install Rtools and have the path to its bin directory +in your PATH variable. You do not need to modify the PATH variable when +installing Rtools. Instead, I would recommend to put the line + +```{r Rprofile, eval = FALSE} +Sys.setenv(PATH = paste("C:/Rtools/bin", Sys.getenv("PATH"), sep=";")) +``` +into your .Rprofile startup file. This is just a text file with some R +code that is executed when your R session starts. It has to be named .Rprofile +and has to be located in your home directory, which will generally be your +Documents folder. You can check the location of the home directory used by R by +issuing + +```{r HOME, eval = FALSE} +Sys.getenv("HOME") +``` + +## Comparison with other solution methods + +First, we build a simple degradation model for a parent compound with one metabolite, +and we remove zero values from the dataset. + +```{r create_SFO_SFO} +library("mkin", quietly = TRUE) +SFO_SFO <- mkinmod( + parent = mkinsub("SFO", "m1"), + m1 = mkinsub("SFO")) +FOCUS_D <- subset(FOCUS_2006_D, value != 0) +``` + +We can compare the performance of the Eigenvalue based solution against the +compiled version and the R implementation of the differential equations using +the benchmark package. In the output of below code, the warnings about zero +being removed from the FOCUS D dataset are suppressed. Since mkin version +0.9.49.11, an analytical solution is also implemented, which is included +in the tests below. + +```{r benchmark_SFO_SFO, fig.height = 3, message = FALSE, warning = FALSE} +if (require(rbenchmark)) { + b.1 <- benchmark( + "deSolve, not compiled" = mkinfit(SFO_SFO, FOCUS_D, + solution_type = "deSolve", + use_compiled = FALSE, quiet = TRUE), + "Eigenvalue based" = mkinfit(SFO_SFO, FOCUS_D, + solution_type = "eigen", quiet = TRUE), + "deSolve, compiled" = mkinfit(SFO_SFO, FOCUS_D, + solution_type = "deSolve", quiet = TRUE), + "analytical" = mkinfit(SFO_SFO, FOCUS_D, + solution_type = "analytical", + use_compiled = FALSE, quiet = TRUE), + replications = 1, order = "relative", + columns = c("test", "replications", "relative", "elapsed")) + print(b.1) +} else { + print("R package rbenchmark is not available") +} +``` + +We see that using the compiled model is by more than a factor of 10 faster +than using deSolve without compiled code. + +## Model without analytical solution + +This evaluation is also taken from the example section of mkinfit. No analytical +solution is available for this system, and now Eigenvalue based solution +is possible, so only deSolve using with or without compiled code is +available. + +```{r benchmark_FOMC_SFO, fig.height = 3, warning = FALSE} +if (require(rbenchmark)) { + FOMC_SFO <- mkinmod( + parent = mkinsub("FOMC", "m1"), + m1 = mkinsub( "SFO")) + + b.2 <- benchmark( + "deSolve, not compiled" = mkinfit(FOMC_SFO, FOCUS_D, + use_compiled = FALSE, quiet = TRUE), + "deSolve, compiled" = mkinfit(FOMC_SFO, FOCUS_D, quiet = TRUE), + replications = 1, order = "relative", + columns = c("test", "replications", "relative", "elapsed")) + print(b.2) + factor_FOMC_SFO <- round(b.2["1", "relative"]) +} else { + factor_FOMC_SFO <- NA + print("R package benchmark is not available") +} +``` + +Here we get a performance benefit of a factor of +`r factor_FOMC_SFO` +using the version of the differential equation model compiled from C code! + +This vignette was built with mkin `r utils::packageVersion("mkin")` on + +```{r sessionInfo, echo = FALSE} +cat(utils::capture.output(utils::sessionInfo())[1:3], sep = "\n") +if(!inherits(try(cpuinfo <- readLines("/proc/cpuinfo")), "try-error")) { + cat(gsub("model name\t: ", "CPU model: ", cpuinfo[grep("model name", cpuinfo)[1]])) +} +``` diff --git a/vignettes/web_only/mkin_benchmarks.rda b/vignettes/web_only/mkin_benchmarks.rda Binary files differindex 268e5efe..c88ca4d6 100644 --- a/vignettes/web_only/mkin_benchmarks.rda +++ b/vignettes/web_only/mkin_benchmarks.rda |