Created
February 27, 2017 10:58
-
-
Save western/fd16a46e2af56ae2dd66f53a714d2fec 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
use strict; | |
use warnings; | |
use Data::Dumper; | |
use Time::HiRes; | |
use AnyEvent; | |
use AnyEvent::HTTP; | |
my @list = ( | |
'https://www.kleos.ru/', | |
'https://news.gnezdo.ru/', | |
'https://shop.gnezdo.ru/', | |
'https://www.gnezdo.ru/', | |
); | |
my $time_info = {}; | |
my $time_start = Time::HiRes::time(); | |
my $cv = AnyEvent->condvar; | |
for my $url(@list){ | |
print "get url [$url]\n"; | |
$cv->begin; | |
http_get $url, sub{ | |
my ($html) = @_; | |
$time_info->{$url} = Time::HiRes::time()-$time_start; | |
$cv->end; | |
}; | |
} | |
$cv->recv; | |
print Dumper($time_info); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment