Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
On both systems I've tested on (Dual P4, Red Hat and Dual P3, Gentoo both using perl 5.8.3) this takes ~15 seconds to run. The same script without the shared variable runs in a fraction of a second. Example:use strict; use forks; use forks::shared; my $t = time; my %hash : shared = (); share( %hash ); $hash{ $_ } = $_ % 2 for( 1..500 ); print "$_: $hash{ $_ }\n" for( sort { $a <=> $b } keys %hash ); print "Elapsed: " . (time - $t) . "\n"; exit 0;
Anyone have experience using forks::shared who might be able to help me speed this up?use strict; my $t = time; my %hash = (); $hash{ $_ } = $_ % 2 for( 1..500 ); print "$_: $hash{ $_ }\n" for( sort { $a <=> $b } keys %hash ); print "Elapsed: " . (time - $t) . "\n"; exit 0;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: forks::shared speed problem
by perrin (Chancellor) on May 03, 2004 at 19:31 UTC |