Memoizing wrapper for parLapplyLB
parLapplyLBm(cl = NULL, X, fun, ..., chunk.size = NULL)
cl | cluster object |
---|---|
X | list or vector of inputs |
fun | function to apply |
... | additional arguments passed to lapply |
chunk.size | passed to |
list of results.
if(requireNamespace("parallel", quietly = TRUE)) { cl <- parallel::makeCluster(2) fs <- function(x) { x <- x[[1]]; Sys.sleep(1); sin(x) } # without memoization should take 1000 seconds lst <- parLapplyLBm(cl, c(rep(0, 1000), rep(1, 1000)), fs) parallel::stopCluster(cl) }