Parallelisation on 100 additional knodes is necessary that foreach competites with a usual (very slowly) for() loop.
(recall what this means in respect to polluting our environment by higher energy consumption…)
system.time(x <- foreach(b = bvec, .combine = “cbind”) %:%
foreach(a = avec, .combine = “c”) %dopar% {sim(a, b)})
After having a deeper look at the example it turns out the computation time increases linear with complexity of this problem (just as the for loop). Profiling shows that most of the time is wasted by the $ operator which is used internally by foreeach (second which()).
I wonder who can give an example where foreach works fine with respect to computation time?
Matthias