Perl LWP - need get timings: DNS resolving time, ssl connect, etc

Viewed 50

I am using LWP to check website accessibility for HTTPS. But, sometimes there are delays of 3000 ms

sub get_url{
  my $url = shift;
  my $browser = LWP::UserAgent->new;
  $browser->timeout($alltimeout);
  
  eval {
      local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required
      alarm $alltimeout;
      $response = $browser->get($url,
         'User-Agent' => 'CHECKER (Win98; U)',
         'Accept-Charset' => 'utf-8',
      );
      alarm 0;      
  };
  if ($@) {print "$@"; return "Timeout $alltimeout - error!"}
  if ($response->is_success){$resp[0]=200; return $response->content;}
    else {return "ERROR".$response->status_line}
}

i want to check separately: DNS resolving time, ssl connect time, etc for HTTPS.

1 Answers

LWP, and many other modules you'll use, aren't instrumented to produce this sort of tracing, and certainly not in any coherent or consistent fashion. You'd have to delve into the individual modules to provide your own hooks for this.

Do you see the same delays with other browsers, such as curl or wget?

Related