esolkc has asked for the wisdom of the Perl Monks concerning the following question:
Just to simplfy my problem. I have to codes A and B. Code A is much slower than code B, although I should expect the opposite. I am using a i7 2600K CPU. Any comments are appreciated. Thank you!!
Code ACode B#!/usr/bin/perl use Parallel::ForkManager; @all_strings=('110110101000101111', '110010101001011101', '110110111001001110', '110011101001011100', '111010101001011100'); my $pm = new Parallel::ForkManager(4); foreach $string (@all_strings) { my $pid = $pm->start and next; print($string,"\n"); $pm->finish; } $pm->wait_all_children;
#!/usr/bin/perl @all_strings=('110110101000101111', '110010101001011101', '110110111001001110', '110011101001011100', '111010101001011100'); foreach $string (@all_strings) { print($string,"\n"); }
|
|---|