diff options
Diffstat (limited to 'vignettes/compiled_models.html')
-rw-r--r-- | vignettes/compiled_models.html | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/vignettes/compiled_models.html b/vignettes/compiled_models.html index 8fb08136..814f3a52 100644 --- a/vignettes/compiled_models.html +++ b/vignettes/compiled_models.html @@ -10,7 +10,7 @@ <meta name="author" content="Johannes Ranke" /> -<meta name="date" content="2015-06-22" /> +<meta name="date" content="2015-06-23" /> <title>Performance benefit by using compiled model definitions in mkin</title> @@ -65,7 +65,7 @@ img { <div id="header"> <h1 class="title">Performance benefit by using compiled model definitions in mkin</h1> <h4 class="author"><em>Johannes Ranke</em></h4> -<h4 class="date"><em>2015-06-22</em></h4> +<h4 class="date"><em>2015-06-23</em></h4> </div> <div id="TOC"> @@ -77,7 +77,7 @@ img { <div id="benchmark-for-a-model-that-can-also-be-solved-with-eigenvalues" class="section level2"> <h2>Benchmark for a model that can also be solved with Eigenvalues</h2> -<p>This evaluation is taken from the example section of mkinfit. When using an mkin version equal to or greater than 0.9-36 and a compiler (gcc) is installed, you will see a message that the model is being compiled from autogenerated C code when defining a model using mkinmod. The package tests for presence of the gcc compiler using</p> +<p>This evaluation is taken from the example section of mkinfit. When using an mkin version equal to or greater than 0.9-36 and a C compiler (gcc) is available, you will see a message that the model is being compiled from autogenerated C code when defining a model using mkinmod. The <code>mkinmod()</code> function checks for presence of the gcc compiler using</p> <pre class="r"><code>Sys.which("gcc")</code></pre> <pre><code>## gcc ## "/usr/bin/gcc"</code></pre> @@ -86,7 +86,7 @@ img { SFO_SFO <- mkinmod( parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"))</code></pre> -<pre><code>## Compiling differential equation model from auto-generated C code...</code></pre> +<pre><code>## Successfully compiled differential equation model from auto-generated C code.</code></pre> <p>We can compare the performance of the Eigenvalue based solution against the compiled version and the R implementation of the differential equations using the microbenchmark package.</p> <pre class="r"><code>library("microbenchmark") mb.1 <- microbenchmark( @@ -99,18 +99,18 @@ smb.1 <- summary(mb.1)[-1] rownames(smb.1) <- c("deSolve, not compiled", "Eigenvalue based", "deSolve, compiled") print(smb.1)</code></pre> <pre><code>## min lq mean median uq -## deSolve, not compiled 6896.8680 6933.3330 6963.5277 6969.7979 6996.8575 -## Eigenvalue based 933.0581 937.8984 963.5002 942.7388 978.7213 -## deSolve, compiled 784.9729 807.9919 822.4500 831.0110 841.1886 +## deSolve, not compiled 6650.2684 6684.4530 6774.1607 6718.6377 6836.1068 +## Eigenvalue based 903.5520 916.8598 927.3873 930.1676 939.3049 +## deSolve, compiled 751.1205 752.5239 756.1227 753.9273 758.6238 ## max neval -## deSolve, not compiled 7023.9171 3 -## Eigenvalue based 1014.7039 3 -## deSolve, compiled 851.3663 3</code></pre> -<p>We see that using the compiled model is by a factor of 8.4 faster than using the R version with the default ode solver, and it is even faster than the Eigenvalue based solution implemented in R which does not need iterative solution of the ODEs:</p> +## deSolve, not compiled 6953.5760 3 +## Eigenvalue based 948.4423 3 +## deSolve, compiled 763.3202 3</code></pre> +<p>We see that using the compiled model is by a factor of 8.9 faster than using the R version with the default ode solver, and it is even faster than the Eigenvalue based solution implemented in R which does not need iterative solution of the ODEs:</p> <pre class="r"><code>smb.1["median"]/smb.1["deSolve, compiled", "median"]</code></pre> <pre><code>## median -## deSolve, not compiled 8.387131 -## Eigenvalue based 1.134448 +## deSolve, not compiled 8.911519 +## Eigenvalue based 1.233763 ## deSolve, compiled 1.000000</code></pre> </div> <div id="benchmark-for-a-model-that-can-not-be-solved-with-eigenvalues" class="section level2"> @@ -119,7 +119,7 @@ print(smb.1)</code></pre> <pre class="r"><code>FOMC_SFO <- mkinmod( parent = mkinsub("FOMC", "m1"), m1 = mkinsub( "SFO"))</code></pre> -<pre><code>## Compiling differential equation model from auto-generated C code...</code></pre> +<pre><code>## Successfully compiled differential equation model from auto-generated C code.</code></pre> <pre class="r"><code>mb.2 <- microbenchmark( mkinfit(FOMC_SFO, FOCUS_2006_D, use_compiled = FALSE, quiet = TRUE), mkinfit(FOMC_SFO, FOCUS_2006_D, quiet = TRUE), @@ -127,17 +127,17 @@ print(smb.1)</code></pre> smb.2 <- summary(mb.2)[-1] rownames(smb.2) <- c("deSolve, not compiled", "deSolve, compiled") print(smb.2)</code></pre> -<pre><code>## min lq mean median uq -## deSolve, not compiled 14.661881 14.668453 14.701870 14.675025 14.721864 -## deSolve, compiled 1.393051 1.394908 1.415653 1.396764 1.426953 +<pre><code>## min lq mean median uq +## deSolve, not compiled 14.32061 14.336413 14.380847 14.352216 14.410966 +## deSolve, compiled 1.34366 1.344778 1.371116 1.345897 1.384844 ## max neval -## deSolve, not compiled 14.768704 3 -## deSolve, compiled 1.457143 3</code></pre> +## deSolve, not compiled 14.469716 3 +## deSolve, compiled 1.423791 3</code></pre> <pre class="r"><code>smb.2["median"]/smb.2["deSolve, compiled", "median"]</code></pre> <pre><code>## median -## deSolve, not compiled 10.50644 +## deSolve, not compiled 10.66368 ## deSolve, compiled 1.00000</code></pre> -<p>Here we get a performance benefit of a factor of 10.5 using the version of the differential equation model compiled from C code using the inline package!</p> +<p>Here we get a performance benefit of a factor of 10.7 using the version of the differential equation model compiled from C code using the inline package!</p> <p>This vignette was built with mkin 0.9.37 on</p> <pre><code>## R version 3.2.1 (2015-06-18) ## Platform: x86_64-pc-linux-gnu (64-bit) |