I am finding that the speed performance of PARFOR is greatly impacted depending on whether certain inconsequential lines in the code are commented out or not. In particular, when running the code below with a pool of 12 workers, I obtain a time of 26 sec (4 times that of a normal for loop).
However, if I comment out either the first line (thus converting the mfile to a script) or if I comment out the inconsequential line
the time drops sharply to less than 1 sec!!
This is under Windows 7 64-bit. Processor is Intel Xeon X5680 @3.33 Ghz, dual hexacore. I've tested with R2011b,R2012b,R2013b, all with similar results.
Can anyone reproduce this? Is there something obvious that I'm not seeing?