Created
August 2, 2013 02:42
-
-
Save anonymous/6137144 to your computer and use it in GitHub Desktop.
This file contains 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/perl | |
use strict; | |
use warnings; | |
use Coro; | |
use AnyEvent::HTTP; | |
use Benchmark; | |
my $T0=Benchmark->new; | |
my $url="http://www.baidu.com"; | |
my @coro; | |
#my $lock = new Coro::Semaphore 10; | |
for (1...1000){ | |
push @coro, async{ | |
# my $guard = $lock->guard; | |
http_get $url, cb => Coro::rouse_cb; | |
my @res = Coro::rouse_wait; | |
print $_[0]."done!\n"; | |
} $_; | |
} | |
$_->join foreach @coro; | |
my $T1=Benchmark->new; | |
my $td = Benchmark::timediff($T1, $T0); | |
print Benchmark::timestr($td)."\n"; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment