Created
December 10, 2010 21:58
-
-
Save ajdamico/736887 to your computer and use it in GitHub Desktop.
run multicore processing in the windows 64 bit version of R
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(snowfall) | |
bigProcess <- function( x ) { | |
mean( replicate ( 10^6 , max( rnorm( 100 , x ) ) ) ) | |
} | |
#run the function twice in parallel | |
start <- Sys.time() | |
sfInit(cpus=2,type='SOCK',parallel=TRUE) | |
sfSapply( c(1,5) , bigProcess ) | |
Sys.time() - start | |
#faster than running it twice sequentially | |
start <- Sys.time() | |
bigProcess( 1 ) | |
bigProcess( 5 ) | |
Sys.time() - start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment