I stripped both pieces of code down to the bare minimum of calculating just $max_workers (1st solution) and $auto_max_workers (2nd solution). I ran some benchmarks on these last night.
The "$max_workers (1st solution)" ran about 15 times faster than "$auto_max_workers (2nd solution)". This is not overly surprising: calculating $max_workers is mostly just arithmetic; calculating $auto_max_workers involves instantiating a temporary object and then some arithmetic.
In the absence of other advice, "$max_workers (1st solution)" will end up in Kens::MCE::Util (or whatever I decide to call it). I've implemented nothing as yet; however, expected usage would probably be something like:
... use Kens::MCE::Util 'get_max_workers'; ... my $percent; # value from user input, config file, etc. ... my $mce = MCE::->new( max_workers => get_max_workers($percent), ... ); ...
— Ken
In reply to Re: MCE - max_workers [Benchmark]
by kcott
in thread MCE - max_workers
by kcott
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |