Skip to content

Instantly share code, notes, and snippets.

@dsparks
Created March 4, 2013 15:30
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 dsparks/5083033 to your computer and use it in GitHub Desktop.
Save dsparks/5083033 to your computer and use it in GitHub Desktop.
Another attempt at simplest possible parallel computation in Windows
myFunction <- function(x){prod(1:x)}
myFunction(10)
system.time(lapply(1:10000, myFunction))
library(parallel)
myCluster <- makeCluster(detectCores())
clusterExport(myCluster, ls())
system.time(parSapply(myCluster, 1:10000, myFunction))
stopCluster(myCluster)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment