Created
June 21, 2019 16:29
-
-
Save ha0ye/793b4327627058e0c54685b1b6d4fd45 to your computer and use it in GitHub Desktop.
parallelization within drake targets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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