|No such thing as a small change|
Re^4: Optimizing with Caching vs. Parallelizing (MCE::Map) (Updated)by 1nickt (Abbot)
|on Apr 06, 2020 at 18:49 UTC||Need Help??|
The three MCE::Map exported functions, mce_map, mce_map_f and mce_map_s all return orderly output (since they mimic, well, map).
(You can also get ordered output from a non-map function using an orderly gather() function such as the ones provided in MCE::Candy.)
You could implement a parallelized version of your code without orderly output just using MCE::Flow:
This runs a tiny bit faster on my system, as you might expect. But it's more code than using MCE::Map, as you can see.
Update: But with a non-ordered input sequence, such as keys %hash, or where processing time for each element is likely to vary, this may be a more significant factor. Also note that you can call gather() multiple times from within the user sub being processed by MCE, without returning, so you can view or handle the output as it is produced (by specifying a callback for your gatherer). And then there's MCE::Stream ... ;-)
Hope this is of interest!
The way forward always starts with a minimal test.