Dear all, In my 'simple' computer I was running some experiments to help me understand how faster a multicore lapply will be. I thought it might be interesting for some people to look at the results.
Even though are not accurate, still might be a good indicator how much improvement there can be. A.Case. The classic: for 1:100 for (i in c(1:dimz)){ print(sprintf('Creating the %d map',i)); Shadowlist[,,i]<- GaussRF(x=x, y=y, model=model, grid=TRUE,param=c(mean,variance,nugget,scale,Whit.alpha)) } user system elapsed 1825.699 303.100 1063.352 -------------------------------------------------------------------------- B.Case. Same as above but with lapply instead of for Shadowlist<-lapply(1:dimz, function(i) { print(sprintf('Creating the %d map',i)); GaussRF(x=x, y=y, model=model, grid=TRUE,param=c(mean,variance,nugget,scale,Whit.alpha)) } ) ) user system elapsed 1816.784 296.745 1062.142 ------------------------------------------- C.Case. Foreach is considered to be easier to be applied to manycores. foreach (i=1:dimz) %do% { print(sprintf('Creating the %d map',i)); Shadowlist[,,i]<-f <- GaussRF(x=x, y=y, model=model, grid=TRUE,param=c(mean,variance,nugget,scale,Whit.alpha)) } user system elapsed 1027.058 13.243 1031.849 ----------------------------------- D. Case. The really multicore lapply. Great difference system.time(Shadowlist<-mclapply(1:dimz, function(i) { + #print(sprintf('Creating the %d map',i)); + GaussRF(x=x, y=y, model=model, grid=TRUE,param=c(mean,variance,nugget,scale,Whit.alpha)) + } + ) + ) user system elapsed 263.134 99.639 549.366 ----------------------------------- My computer is a normal four core pc. Great improvement with mlcapply. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.