in reply to Using LWP: is there a way to get the server response time?

Libcurl keeps good information on this kind of thing (see CURLINFO_STARTTRANSFER_TIME). Info: http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html

There's a Perl module: WWW::Curl at http://curl.haxx.se/libcurl/perl/

You could also just record the time at intervals in LWP::Protocol::http::request().

  • Comment on Re: Using LWP: is there a way to get the server response time?

Replies are listed 'Best First'.
Re^2: Using LWP: is there a way to get the server response time?
by Anonymous Monk on May 11, 2007 at 17:35 UTC
    I am not so familar with the LWP internals and never came to the "LWP::Protocol" branch... How would I poll LWP::Protocol::http::request()? By getting the private $sel_timeout var? A code hint would be great!

    I don't want to switch over to curl...
      OK, do a:
      locate Protocol/http.pm
      or similar to find where your LWP::Protocol::http module lives. Mine is in /usr/share/perl5/LWP/Protocol/http.pm. Search for the request() subroutine. Add these lines up at the top of it:
      use Time::HiRes qw(time); my @times;
      Add a line containing "push @times, time();" before the following three lines:
      if ($has_content) { block, ... $response = $self->collect($arg, $response, sub { ... unless ($drop_connection) {
      and then add this at the bottom:
      warn "wrote-request read-headers read-content\n@times\n";
      If this is anything but a quick hack, it might be better to subclass or otherwise hook into LWP::Protocol::http to make it more maintainable. Another approach would be to just do a HEAD and then a GET, with the difference in times being the content-transfer time.