Skip to main content
edited title
Link
Murta
  • 26.4k
  • 6
  • 77
  • 168

Why is ParallelMap[]ParallelMap way slower than Map[]Map

Tweeted twitter.com/#!/StackMma/status/387326597013180416
Source Link
Wizard
  • 2.7k
  • 17
  • 28

Why is ParallelMap[] way slower than Map[]

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?