#!/usr/local/bin/perl -w
=head1 NAME
timefetch - Fetch a web page and time how long it takes
=head1 SCRIPT CATEGORIES
Web
=head1 SYNOPSIS
C
C
=head1 README
This script uses LWP and Time::HiRes to fetch a web page,
parse embedded IMG tags and other tags, download the images,
and time the whole download operation. It is useful for measuring
download times for an entire page with images, and for reporting
errors in downloads (timeouts, connect failures, broken images, etc.).
Complete documentation is available in the script iteself,
in the embedded POD.
=head1 DESCRIPTION
This script uses LWP and Time::HiRes to fetch a web page,
parse embedded IMG tags and other tags, download the images,
and time the whole download operation. It is useful for measuring
download times for an entire page with images, and for reporting
errors in downloads (timeouts, connect failures, broken images, etc.).
Depending on the command line options you use, it can just download
a simgle HTML page or recursively download all embedded images and
applets, and tally a grand total download time and total download size.
This script does not implement a smart browser. It basically does
two kinds of "benchmarks": best-case scenario and absolute worst-case
scenario. The best-case scenario is when a browser downloads just the
contents of a single HTML page, and does not download any images,
because they are in the cache. The worst-case scenario is when
the browser must download each and every image, one after the other.
Neither one of these scenarios exactly matches real-live scenarios
you experience with a browser. However, these numbers are an objective
measurement of a repeatible and well-defined process. You can use
them for straightforward comparison of the download times of
two different web pages, or chart the download time of a single
page during different kinds of loads and traffic patterns.
While doing the downloading, the script checks for certain kinds
of errors. Depending on the exact command options, the program
may abort with a brief message explaining the error and with an
exit value of -1. This makes the script useful as a monitor script
for a web page.
The script can detect the following kinds of errors:
=over 4
=item *
Download of the main web page times out.
=item *
The number of broken images exceeds a configurable number.
=item *
The main web page is not complete (e.g., it's missing "