Created
August 15, 2016 15:39
-
-
Save kylebaron/2d0da708038dac83e033469f228b396b to your computer and use it in GitHub Desktop.
Future multicore
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(future) | |
| library(future.BatchJobs) | |
| library(mrgsolve) | |
| library(dplyr) | |
| library(parallel) | |
| mod <- mrgsolve:::house() | |
| data <- expand.ev(amt=100,ID=1:200) | |
| #plan(eager) | |
| #plan(lazy) | |
| #plan(batchjobs_sge, pathname="simple.tmpl") | |
| plan(multicore) | |
| system.time({ | |
| f <- lapply(1:8, function(i) { | |
| future({ | |
| mod %>% | |
| Req(CP) %>% | |
| data_set(data) %>% | |
| mrgsim(end=24,delta=1) %>% | |
| mutate(rep = i) | |
| }) | |
| }) | |
| }) | |
| plan(eager) | |
| system.time({ | |
| f <- lapply(1:8, function(i) { | |
| future({ | |
| mod %>% | |
| Req(CP) %>% | |
| data_set(data) %>% | |
| mrgsim(end=24,delta=1) %>% | |
| mutate(rep = i) | |
| }) | |
| }) | |
| }) | |
| system.time({ | |
| f <- mclapply(1:8,mc.cores=8, function(i) { | |
| mod %>% | |
| Req(CP) %>% | |
| data_set(data) %>% | |
| mrgsim(end=24,delta=1) %>% | |
| mutate(rep = i) | |
| }) | |
| }) | |
Author
kylebaron
commented
Aug 15, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment