I recently tried to use ParallelMap
instead of Map
and to my surprise encountered that ParallelMap
seems to be slower in general than Map
, which does not make sense to me.
Here is a simple test case, that shows the behavior on my system (tested it on Linux 64 Bit QuadCore i7 and on MacOS DualCore Core2Duo, both running Mathematica 9.0.1):
LaunchKernels[];
f[x_] := Sin[x] + Cos[x] + Tan[x];
test = Table[i, {i, 100000}];
Timing results are the following (and they are consistent, additional kernels have been started before):
Map[f[#] &, test]; // AbsoluteTiming
{0.198230, Null}
ParallelMap[f[#] &, test]; // AbsoluteTiming
{0.650516, Null}
What am I missing here?