Skip to content

Instantly share code, notes, and snippets.

Created August 2, 2013 02:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/6137144 to your computer and use it in GitHub Desktop.
Save anonymous/6137144 to your computer and use it in GitHub Desktop.
#!/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