From 234c9059a95e104917e488a6ddd2313234a96cdc Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Mon, 11 May 2020 05:15:19 +0200 Subject: Avoid merge() and data.frame() in cost function also for deSolve and eigenvalue based solutions. This noticeably increases performance for these methods, see test.log and benchmark vignette. --- docs/articles/web_only/benchmarks.html | 248 ++++++++++++++------------------- 1 file changed, 103 insertions(+), 145 deletions(-) (limited to 'docs/articles/web_only') diff --git a/docs/articles/web_only/benchmarks.html b/docs/articles/web_only/benchmarks.html index 4fb76fa2..ad7cf62c 100644 --- a/docs/articles/web_only/benchmarks.html +++ b/docs/articles/web_only/benchmarks.html @@ -6,19 +6,19 @@ Benchmark timings for mkin on various systems • mkin - - - - + + + + + - - + - +
@@ -87,12 +94,12 @@
@@ -103,192 +110,143 @@

Systems

Each system is characterized by its CPU type, the operating system type and the mkin version.

-
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)
-}
-
# Parent only
-t1 <- system.time(mmkin_bench(c("SFO", "FOMC", "DFOP", "HS"), list(FOCUS_2006_C, FOCUS_2006_D)))[["elapsed"]]
-t2 <- system.time(mmkin_bench(c("SFO", "FOMC", "DFOP", "HS"), list(FOCUS_2006_C, FOCUS_2006_D), error_model = "tc"))[["elapsed"]]
+
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)
+}
+
FOCUS_C <- FOCUS_2006_C
+FOCUS_D <- subset(FOCUS_2006_D, value != 0)
+# Parent only
+t1 <- system.time(mmkin_bench(c("SFO", "FOMC", "DFOP", "HS"), list(FOCUS_C, FOCUS_D)))[["elapsed"]]
+t2 <- system.time(mmkin_bench(c("SFO", "FOMC", "DFOP", "HS"), list(FOCUS_C, FOCUS_D), error_model = "tc"))[["elapsed"]]
## Warning in mkinfit(models[[model_index]], datasets[[dataset_index]], ...): Optimisation did not converge:
+## iteration limit reached without convergence (10)
+
+## Warning in mkinfit(models[[model_index]], datasets[[dataset_index]], ...): Optimisation did not converge:
 ## iteration limit reached without convergence (10)
- +
# One metabolite
+SFO_SFO <- mkinmod(
+  parent = mkinsub("SFO", "m1"),
+  m1 = mkinsub("SFO"))
## Successfully compiled differential equation model from auto-generated C code.
- +
FOMC_SFO <- mkinmod(
+  parent = mkinsub("FOMC", "m1"),
+  m1 = mkinsub("SFO"))
## Successfully compiled differential equation model from auto-generated C code.
- +
DFOP_SFO <- mkinmod(
+  parent = mkinsub("FOMC", "m1"),
+  m1 = mkinsub("SFO"))
## Successfully compiled differential equation model from auto-generated C code.
-
t3 <- system.time(mmkin_bench(list(SFO_SFO, FOMC_SFO, DFOP_SFO), list(FOCUS_2006_D)))[["elapsed"]]
-
## Warning in mkinfit(models[[model_index]], datasets[[dataset_index]], ...):
-## Observations with value of zero were removed from the data
-
## Warning in mkinfit(models[[model_index]], datasets[[dataset_index]], ...):
-## Observations with value of zero were removed from the data
+
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), error_model = "obs"))[["elapsed"]]
+
+# Two metabolites, synthetic data
+m_synth_SFO_lin <- mkinmod(parent = mkinsub("SFO", "M1"),
+                           M1 = mkinsub("SFO", "M2"),
+                           M2 = mkinsub("SFO"),
+                           use_of_ff = "max", quiet = TRUE)
+
+m_synth_DFOP_par <- mkinmod(parent = mkinsub("DFOP", c("M1", "M2")),
+                           M1 = mkinsub("SFO"),
+                           M2 = mkinsub("SFO"),
+                           use_of_ff = "max", quiet = TRUE)
+
+SFO_lin_a <- synthetic_data_for_UBA_2014[[1]]$data
 
-## Warning in mkinfit(models[[model_index]], datasets[[dataset_index]], ...):
-## Observations with value of zero were removed from the data
-
t4 <- system.time(mmkin_bench(list(SFO_SFO, FOMC_SFO, DFOP_SFO), list(subset(FOCUS_2006_D, value != 0)), error_model = "tc"))[["elapsed"]]
-t5 <- system.time(mmkin_bench(list(SFO_SFO, FOMC_SFO, DFOP_SFO), list(FOCUS_2006_D), error_model = "obs"))[["elapsed"]]
-
## Warning in mkinfit(models[[model_index]], datasets[[dataset_index]], ...):
-## Observations with value of zero were removed from the data
+DFOP_par_c <- synthetic_data_for_UBA_2014[[12]]$data
 
-## Warning in mkinfit(models[[model_index]], datasets[[dataset_index]], ...):
-## Observations with value of zero were removed from the data
+t6 <- system.time(mmkin_bench(list(m_synth_SFO_lin), list(SFO_lin_a)))["elapsed"]
+t7 <- system.time(mmkin_bench(list(m_synth_DFOP_par), list(DFOP_par_c)))["elapsed"]
 
-## Warning in mkinfit(models[[model_index]], datasets[[dataset_index]], ...):
-## Observations with value of zero were removed from the data
-
# Two metabolites, synthetic data
-m_synth_SFO_lin <- mkinmod(parent = mkinsub("SFO", "M1"),
-                           M1 = mkinsub("SFO", "M2"),
-                           M2 = mkinsub("SFO"),
-                           use_of_ff = "max", quiet = TRUE)
-
-m_synth_DFOP_par <- mkinmod(parent = mkinsub("DFOP", c("M1", "M2")),
-                           M1 = mkinsub("SFO"),
-                           M2 = mkinsub("SFO"),
-                           use_of_ff = "max", quiet = TRUE)
-
-SFO_lin_a <- synthetic_data_for_UBA_2014[[1]]$data
-
-DFOP_par_c <- synthetic_data_for_UBA_2014[[12]]$data
-
-t6 <- system.time(mmkin_bench(list(m_synth_SFO_lin), list(SFO_lin_a)))["elapsed"]
-t7 <- system.time(mmkin_bench(list(m_synth_DFOP_par), list(DFOP_par_c)))["elapsed"]
-
-t8 <- system.time(mmkin_bench(list(m_synth_SFO_lin), list(SFO_lin_a), error_model = "tc"))["elapsed"]
-t9 <- system.time(mmkin_bench(list(m_synth_DFOP_par), list(DFOP_par_c), error_model = "tc"))["elapsed"]
-
-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)
-mkin_benchmarks
-
##                                                                                                       CPU
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 AMD Ryzen 7 1700 Eight-Core Processor
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 AMD Ryzen 7 1700 Eight-Core Processor
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 AMD Ryzen 7 1700 Eight-Core Processor
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 AMD Ryzen 7 1700 Eight-Core Processor
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 AMD Ryzen 7 1700 Eight-Core Processor
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 AMD Ryzen 7 1700 Eight-Core Processor
-##                                                                        OS
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 Linux
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 Linux
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 Linux
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 Linux
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 Linux
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 Linux
-##                                                                         mkin
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 0.9.48.1
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 0.9.49.1
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 0.9.49.2
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 0.9.49.3
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 0.9.49.4
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 0.9.49.6
-##                                                                        t1
+t8 <- system.time(mmkin_bench(list(m_synth_SFO_lin), list(SFO_lin_a), error_model = "tc"))["elapsed"]
+t9 <- system.time(mmkin_bench(list(m_synth_DFOP_par), list(DFOP_par_c), error_model = "tc"))["elapsed"]
+
+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)
+mkin_benchmarks[, -c(1:3)]
+
##                                                                        t1
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 3.610
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 8.184
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 7.064
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 7.296
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 5.936
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 5.901
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.50   1.683
 ##                                                                         t2
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 11.019
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 22.889
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 12.558
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 21.239
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 20.545
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 36.164
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.50    3.862
 ##                                                                        t3
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 3.764
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 4.649
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 4.786
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 4.510
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 4.446
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 4.510
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.50   1.369
 ##                                                                         t4
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 14.347
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 13.789
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2  8.461
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 13.805
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 15.335
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 30.849
-##                                                                         t5
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1  9.495
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1  6.395
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2  5.675
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3  7.386
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4  6.002
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 10.545
-##                                                                        t6
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 2.623
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 2.542
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 2.723
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 2.643
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 2.635
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 2.563
-##                                                                        t7
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 4.587
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 4.128
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 4.478
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 4.374
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 4.259
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 4.252
-##                                                                        t8
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 7.525
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 4.632
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 4.862
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3  7.02
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 4.737
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 7.865
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.50    6.104
+##                                                                        t5    t6
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 9.495 2.623
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 6.395 2.542
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 5.675 2.723
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 7.386 2.643
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 6.002 2.635
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.50   2.718 0.752
+##                                                                        t7    t8
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 4.587 7.525
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 4.128 4.632
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 4.478 4.862
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 4.374  7.02
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 4.259 4.737
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.50   1.214 1.276
 ##                                                                         t9
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 16.621
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1  8.171
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2  7.618
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 11.124
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4  7.763
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 16.195
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.50    2.858
 ##                                                                       t10
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 8.576
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 3.676
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 3.579
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 5.388
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 3.427
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 7.729
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.50   2.032
 ##                                                                        t11
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 31.267
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1  5.636
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2  5.574
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3  7.365
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4  5.626
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 10.787
-
save(mkin_benchmarks, file = "~/git/mkin/vignettes/mkin_benchmarks.rda")
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.50 2.973
+
save(mkin_benchmarks, file = "~/git/mkin/vignettes/mkin_benchmarks.rda")
- @@ -299,7 +257,7 @@
-

Site built with pkgdown 1.4.1.

+

Site built with pkgdown 1.5.1.

-- cgit v1.2.1