Last active
August 29, 2015 13:55
-
-
Save CnrLwlss/8709261 to your computer and use it in GitHub Desktop.
This file contains 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(parallel) | |
cores = 5 | |
bigN = 50000000 | |
# Function which can take a noticeable time to run for large N | |
sumnorm = function(N) sum(rnorm(N)) | |
cl = makeCluster(cores) | |
parallel = system.time(parLapply(cl,replicate(cores,bigN),sumnorm)) | |
sequential = system.time(lapply(replicate(cores,bigN),sumnorm)) | |
stopCluster(cl) | |
parallel | |
sequential |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment