Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I'm starting a small project wherein a script will use LWP to get a copy of a remote website. I'd like to find the amount of time that it takes for the script to pull the full index page of the URL I am handing to it, so I can log the number and see how it varies throughout the day. I question whether or not my code is valid for finding the true elapse time. This code is just for testing and doesnt take into consideration, http errors:

#!/usr/bin/perl -w + use strict; + use LWP::UserAgent; use Sys::Hostname; my $agent = new LWP::UserAgent( timeout => 30 ); my $site = 'http://www.perlmonks.org/'; my $response = new HTTP::Request GET => $site; my $start = time(); my $page = $agent->request($response); my $end = time(); my $sum = $end - $start; print "\n$end - $start = $sum";

This doesnt break down into ms, however I'm not that concerned about precise timing for the moment. I would however, like to be able to confirm when the entire page is downloaded and then compare start and finish times. Are there any LWP builtins that provide elapsed time? Am I really just getting the response time for the initial GET of the index page but none of the images held within it?

Thank you for your input -c


In reply to Transaction time for LWP::UserAgent GET by c

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (1)
As of 2024-04-25 19:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found