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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.