"Using '/tmp' as the temp directory is badly broken"
Thank you very much for the hint.
"...What's wrong with for my n (@numbers)..."
Nothing is wrong with it. But the iterator was significantly faster in the example in my OP.
Update: Please see also this bug
Update 2:
"...iterator was ... faster"
I thought this might be of interest:
karls-mac-mini:monks karl$ ./forker.pl
numbers: 2000
processes: 4
fork: 31.1171970367432
for: 40.2419550418854
I used this code...
while(defined( my $number = $iterator->())) {
$pm->start($number) and next;
my $factorial = Math::BigInt->bfac($number);
$pm->finish( 0, \$factorial );
}
$pm->wait_all_children;
...vs. this:
for my $number (@numbers) {
$pm->start($number) and next;
my $factorial = Math::BigInt->bfac($number);
$pm->finish( 0, \$factorial );
}
$pm->wait_all_children;
Best regards, Karl
«The Crux of the Biscuit is the Apostrophe»
|