Skip to content

Instantly share code, notes, and snippets.

@ha0ye
Created June 21, 2019 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ha0ye/793b4327627058e0c54685b1b6d4fd45 to your computer and use it in GitHub Desktop.
Save ha0ye/793b4327627058e0c54685b1b6d4fd45 to your computer and use it in GitHub Desktop.
parallelization within drake targets
library(drake)
library(furrr)
future::plan(future::multiprocess)
tictoc::tic()
params = data.frame(t = c(1, 2, 3, 1, 2, 3))
out = purrr::pmap(params, Sys.sleep)
tictoc::toc()
tictoc::tic()
params = data.frame(t = c(1, 2, 3, 1, 2, 3))
out = future_pmap(params, Sys.sleep)
tictoc::toc()
my_plan <- drake_plan(
params = data.frame(t = c(1, 2, 3, 1, 2, 3)),
out = future_pmap(params, Sys.sleep)
)
future::plan(future.callr::callr)
tictoc::tic()
clean()
make(my_plan)
tictoc::toc()
tictoc::tic()
clean()
make(my_plan, parallelism = "future", jobs = 3)
tictoc::toc()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment