3 ms·
what's funny is that the code compiles the small map-reduce and the for loop to exactly the same bytecode probably. :)
by liveoneggs 9y ago
what's funny is that the code compiles the small map-reduce and the for loop to exactly the same bytecode probably. :)
- RandomInteger4 9y agoNot my area of expertise, so I want to ask this question: Do compiler optimizations exist to automatically parallelize a for loop, which can be parallelized, no matter how to programmer wrote their for loop? If not, then map / reduce offers non-trivial performance benefits over a for loop. Mapping, as far as I'm aware, is "embarrassingly parallel", assuming the function that's mapped is pure? I think?
- deleted 9y ago[deleted]
- liveoneggs 9y agoin perl6 this is done with the hyper operator, but for a small data set a for loop (non parallel) will almost always just run faster.
- fpisfun 9y agoNo, map reduce can be run in parallel, at least in some cases.