Using the foreach package, I was expecting the following line to run in about 10 seconds
system.time(foreach (i=1:5, .combine='c') %do% {Sys.sleep(2);i})
user system elapsed
0.053 0.011 10.012
and the following line to run in about 2 seconds
system.time(foreach (i=1:5, .combine='c') %dopar% {Sys.sleep(2);i})
user system elapsed
0.069 0.017 10.019
but it doesn't work.
I am on a Mac OSX, my machine has 16 processors and nothing heavy is currently running. I don't get any error or warning message.
i
. In the first paragraph of page 8 one can read:To make any of the previous examples run in parallel, all you have to do is to replace %do% with %dopar%
. What is my mistake? – Changteh