Skip to content

Performance note #1

@jorainer

Description

@jorainer

This is only for later - once things are in place:
In the Spectrum constructors in R (like Spectra2_mz_sorted) if e.g. metadata is not provided you have different options to create the list of list:

meta_list <- replicate(n = 1000, list())

mlist <- list(list())
meta_list_2 <- mlist[rep(1, 1000)]

The second option would be preferable:

library(microbenchmark)
microbenchmark(replicate(n = 1000, list()), mlist[rep(1, 1000)])
Unit: microseconds
                        expr     min       lq      mean   median      uq
 replicate(n = 1000, list()) 550.126 563.1315 593.64833 573.0880 587.253
         mlist[rep(1, 1000)]  14.504  14.8945  15.79718  15.2915  15.910
     max neval cld
 991.453   100   b
  43.616   100  a 

Same for data.frame:

dfl <- list(data.frame())
microbenchmark(replicate(n = 1000, data.frame()), dfl[rep(1, 1000)])
Unit: microseconds
                              expr       min         lq        mean     median
 replicate(n = 1000, data.frame()) 10170.537 11250.9030 12045.73504 11662.1910
                 dfl[rep(1, 1000)]    11.465    13.2695    14.61273    14.2835
         uq       max neval cld
 12635.1265 15908.483   100   b
    15.7515    22.069   100  a 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions