Skip to contents

A helper method to find the best multithreading configuration for your computer

Usage

optimizeCoreGx(sample_data, set = FALSE, report = !set)

Arguments

sample_data

TreatmentResponseExperiment

set

logical(1) Should the function modify your R environment with the predicted optimal settings? This changes the global state of your R session!

report

logical(1) Should a data.frame of results be returned by number of threads and operation be returned? Defaults to !set.

Value

If set=TRUE, modifies data.table threads via setDTthreads(), otherwise displays a message indicating the optimal number of threads. If report=TRUE, also returns a data.frame of the benchmark results.

Examples

# \donttest{
  data(merckLongTable)
  optimizeCoreGx(merckLongTable)
#> Benchmarking assay(sample_data, withDimnames=TRUE)...
#> Running with:
#>   nthread
#> 1       1
#> 2       2
#> Benchmarking assays(sample_data)...
#> Running with:
#>   nthread
#> 1       1
#> 2       2
#> Benchmarking reindex(sample_data)...
#> Running with:
#>   nthread
#> 1       1
#> 2       2
#> Optimal cores for your machine are: 2
#>                                          expression nthread     min_sec
#> 1 { assay(sample_data, 1, withDimnames = TRUE) NA }       1 0.004544732
#> 2 { assay(sample_data, 1, withDimnames = TRUE) NA }       2 0.004496732
#> 3                        { assays(sample_data) NA }       1 0.006184407
#> 4                        { assays(sample_data) NA }       2 0.006097405
#> 5                       { reindex(sample_data) NA }       1 0.007182057
#> 6                       { reindex(sample_data) NA }       2 0.007184832
#>    median_sec total_sec mem_alloc_mb  itr/sec   gc/sec
#> 1 0.004641513 0.4765041     3.318416 207.7632 4.197235
#> 2 0.004560126 0.4768231     2.181288 213.9158 4.194428
#> 3 0.006271681 0.4724598     2.738928 158.7437 4.233165
#> 4 0.006179117 0.4757688     2.738928 159.7415 4.203722
#> 5 0.007282770 0.4861001     1.845168 135.7745 2.057190
#> 6 0.007281953 0.4908436     1.537576 136.4997 2.037309
# }