简体   繁体   English

Perl LWP - 需要获取时间:DNS 解析时间,ssl 连接等

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

I am using LWP to check website accessibility for HTTPS.我正在使用 LWP 检查 HTTPS 的网站可访问性。 But, sometimes there are delays of 3000 ms但是,有时会有 3000 毫秒的延迟

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.我想单独检查:HTTPS 的 DNS 解析时间、ssl 连接时间等。

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. LWP 以及您将使用的许多其他模块都无法生成这种跟踪,当然也不会以任何连贯或一致的方式进行。 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?您是否看到其他浏览器出现相同的延迟,例如 curl 或 wget?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM