Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment