Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
Re: Parallel::ForkManager right approachby roboticus (Chancellor) |
on Oct 13, 2019 at 17:59 UTC ( [id://11107401]=note: print w/replies, xml ) | Need Help?? |
To test your code, I added this to the end:
And it seemed to do what you'd expect:
Of course, if your APIs contend with each other for resources (such as hitting the hard drive a lot), you may not save much time. If they run well in parallel as the simple sleep timers do in the case I tried, you can save much more. Make sure you look at what your different APIs do to see if they conflict with each other. Bundling IO-heavy operations with CPU-heavy operations tends to work well to save you time. Similarly, you can *lose* time if you have processes always contending for the same resources. Note that you have a minor bug, though, in that you never run API_6. I'm assuming the bug was introduced by your simplification of the test code. ...roboticus When your only tool is a hammer, all problems look like your thumb.
In Section
Seekers of Perl Wisdom
|
|