Changeset d6dd05b in lab.git


Ignore:
Timestamp:
Nov 2, 2013 11:58:01 PM (10 years ago)
Author:
Ken-ichi Mito <mitty@…>
Branches:
master
Children:
257952a
Parents:
512faed
Message:

fix: repeat loops in child processes

  • '$pm->finish and then $pm->start' loop costs more CPU time
File:
1 edited

Legend:

Unmodified
Added
Removed
  • misc/httpbench.pl

    r512faed rd6dd05b  
    3535 
    3636my $pm = Parallel::ForkManager->new($concurrency); 
    37 for (my $i = 0; $i < $loops; $i++) { 
    38     for (my $child = 0; $child < $concurrency; $child++) { 
    39         $pm->start and next; 
     37for (my $child = 0; $child < $concurrency; $child++) { 
     38    if ($pm->start) { 
     39        warn "forks $child/$concurrency child ...\n"; 
     40        next; 
     41    } 
     42        for (my $i = 0; $i < $loops; $i++) { 
     43            print STDERR "processing $i/$loops loop\r"; 
    4044            foreach my $url (@urls) { 
    4145                get($url) or warn "fail: $url\n"; 
    4246                sleep($wait); 
    4347            } 
    44         $pm->finish; 
    45     } 
    46     print STDERR " ... ", $num * $concurrency * ($i + 1), " requesting\r"; 
     48        } 
     49    $pm->finish; 
    4750} 
    4851$pm->wait_all_children; 
Note: See TracChangeset for help on using the changeset viewer.