Last active
November 10, 2016 08:02
-
-
Save qgp9/8f32af4ff0dfe78ad67d3305d990dd6b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 0.000874996185302734 1 | |
| 0.00116109848022461 2 | |
| 0.00148200988769531 3 | |
| 0.0019071102142334 4 | |
| 1.00795602798462 5 | |
| 1.0085711479187 6 | |
| 1.00913310050964 7 | |
| 1.0098090171814 8 | |
| 2.01733994483948 9 | |
| 2.01780605316162 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1.00159978866577 5 | |
| 1.0016028881073 3 | |
| 1.00160098075867 1 | |
| 1.00160384178162 4 | |
| 1.00160098075867 2 | |
| 2.00454998016357 9 | |
| 2.00453996658325 8 | |
| 2.00453901290894 7 | |
| 2.00454688072205 10 | |
| 2.00453901290894 6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| use v5.18; | |
| use Time::HiRes 'time'; | |
| use Parallel::ForkManager; | |
| my $pm = new Parallel::ForkManager(4); | |
| my @links = 1..10; | |
| my $btime = time; | |
| foreach my $link (@links) { | |
| $pm->start and next; # do the fork | |
| say ((time-$btime),"\t",$link); | |
| $pm->finish; # do the exit in the child process | |
| } | |
| $pm->wait_all_children; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| use v5.18; | |
| use Time::HiRes 'time'; | |
| my @links = 1..10; | |
| my $btime = time; | |
| my $nfork = 0; | |
| foreach my $link (@links) { | |
| my $pid = fork(); | |
| die if not defined $pid; | |
| if ( $pid ){ | |
| $nfork++; | |
| if ($nfork > 4){ | |
| wait; | |
| $nfork--; | |
| } | |
| }else{ | |
| sleep 1; | |
| say ((time-$btime),"\t",$link); | |
| exit; | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment