How to check if %dopar% really run parallel?
Is there any way to check that %dopar% really runs parallel? The following code (on a dual core laptop running windows+R 2.11.0pat and on Linux+R2.11.0) runs %dopar% more slowly than the same %do% code. BTW, if you see any obvious mistake in the code... Thanks! mario library(doSNOW) library(foreach) fun <- function() for(q in 1:1000000) sqrt(3) system.time(times(10000) %do% fun, gcFirst = TRUE) # user system elapsed # 5.74 0.01 6.24 cl <- makeCluster(2, type = "SOCK") registerDoSNOW(cl) system.time(times(10000) %dopar% fun, gcFirst = TRUE) # user system elapsed # 7.89 0.19 9.01 stopCluster(cl)
Ing. Mario Valle Data Analysis and Visualization Group | http://www.cscs.ch/~mvalle Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82