Open-Systems-Pharmacology / OSPSuite-R

R package for the OSPSuite
https://www.open-systems-pharmacology.org/OSPSuite-R/
Other
29 stars 12 forks source link

Implement pkAnalysisTODataFrame() without saving to csv #1497

Open rengelke opened 6 days ago

rengelke commented 6 days ago

Related to #794

Implemented pkAnalysisToDataFrame without saving to csv-file. Given the exposed .NET methods, data extraction required cell-by-cell processing, resulting in many .NET calls. This repeated crossing of the R/.NET boundary seems to negatively impact performance.

@PavelBal @rwmcintosh : Should we keep this implementation or add a dedicated C# method for bulk data retrieval?

devtools::load_all(".")

sim <- loadTestSimulation("S1")
clearOutputs(sim)
outputs <- "Organism|VenousBlood|*|*"
addOutputs(outputs, sim)
results <- runSimulations(sim)[[1]]
pkAnalyses <- calculatePKAnalyses(results)

library(microbenchmark)
benchmark_results <- microbenchmark(
  res1 = pkAnalysesToDataFrame(pkAnalyses),  # existing method
  res2 = pkAnalysesToDataFrame_(pkAnalyses), # w/o saving to csv
  times = 50L
)

benchmark_results
#> Unit: milliseconds
#>  expr     min       lq      mean   median       uq      max neval cld
#>  res1 28.0700  30.5758  38.41138  31.6742  35.0210 134.4465    50  a 
#>  res2 84.8444 106.6241 246.30354 135.9451 322.5596 747.7574    50   b
PavelBal commented 6 days ago

add a dedicated C# method for bulk data retrieval?