#!/usr/bin/perl
use strict; use warnings; use 5.010;
use Data::Dumper; use HTTP::Tiny;
use Time::HiRes 'gettimeofday', 'tv_interval';
use MCE; use MCE::Shared;
my $ua = HTTP::Tiny->new( timeout => 10 );
my @urls = qw< gap.com amazon.com ebay.com lego.com wunderground.com
imdb.com underarmour.com disney.com espn.com dailymail.com >;
my $report = MCE::Shared->hash;
my $process = MCE::Shared->scalar;
$process = 0;
MCE->new( max_workers => 6 )->foreach( \@urls, sub {
my $start = [gettimeofday];
$process++;
say $process."->GETting https://".$_;
$ua->get('https://' . $_);
$report->set( $_, tv_interval($start, [gettimeofday]) );
});
say Dumper $report->export;
####
1->GETting https://gap.com
1->GETting https://amazon.com
1->GETting https://ebay.com
1->GETting https://lego.com
1->GETting https://wunderground.com
1->GETting https://imdb.com
2->GETting https://underarmour.com
2->GETting https://disney.com
2->GETting https://espn.com
3->GETting https://dailymail.com
$VAR1 = bless( {
'disney.com' => '1.15682',
'amazon.com' => '4.607657',
'wunderground.com' => '0.46855',
'dailymail.com' => '2.355818',
'espn.com' => '1.170818',
'gap.com' => '3.819699',
'ebay.com' => '1.479624',
'underarmour.com' => '2.919818',
'imdb.com' => '2.540127',
'lego.com' => '0.919592'
}, 'MCE::Shared::Hash' );
##
##
1->GETting https://gap.com
2->GETting https://amazon.com
3->GETting https://ebay.com
4->GETting https://lego.com
5->GETting https://wunderground.com
6->GETting https://imdb.com
7->GETting https://underarmour.com
8->GETting https://disney.com
9->GETting https://espn.com
10->GETting https://dailymail.com
$VAR1 = bless( {
'disney.com' => '1.15682',
'amazon.com' => '4.607657',
'wunderground.com' => '0.46855',
'dailymail.com' => '2.355818',
'espn.com' => '1.170818',
'gap.com' => '3.819699',
'ebay.com' => '1.479624',
'underarmour.com' => '2.919818',
'imdb.com' => '2.540127',
'lego.com' => '0.919592'
}, 'MCE::Shared::Hash' );