L
Leif Wessman
Hi,
I'm using the LWP:
arallel package to connect to several websites at
the same time. Now I would like to know how long time each request
takes (inluding redirects). How can I find that information?
I've tried the following but I can't get it to work. One problem is
that I don't know how to access the variable from my main script. One
other problem is that the accesstime is counted once per request, and
it doesn't take into account the redirects:
package MyUA;
use Exporter();
use LWP:
arallel::UserAgent qw
CALLBACK);
@ISA = qw(LWP:
arallel::UserAgent Exporter);
@EXPORT = @LWP:
arallel::UserAgent::EXPORT_OK;
use Time::HiRes qw(gettimeofday tv_interval);
my $start_time;
my $end_time;
my $accesstime;
sub on_connect {
my ($self, $request, $response, $entry) = @_;
$start_time = [ gettimeofday ];
}
sub on_return {
my ($self, $request, $response, $entry) = @_;
$end_time = [ gettimeofday ];
my $accesstime = tv_interval($start_time,$end_time);
}
1;
I'm using the LWP:
the same time. Now I would like to know how long time each request
takes (inluding redirects). How can I find that information?
I've tried the following but I can't get it to work. One problem is
that I don't know how to access the variable from my main script. One
other problem is that the accesstime is counted once per request, and
it doesn't take into account the redirects:
package MyUA;
use Exporter();
use LWP:
@ISA = qw(LWP:
@EXPORT = @LWP:
use Time::HiRes qw(gettimeofday tv_interval);
my $start_time;
my $end_time;
my $accesstime;
sub on_connect {
my ($self, $request, $response, $entry) = @_;
$start_time = [ gettimeofday ];
}
sub on_return {
my ($self, $request, $response, $entry) = @_;
$end_time = [ gettimeofday ];
my $accesstime = tv_interval($start_time,$end_time);
}
1;