On Wed, Apr 15, 2009 at 10:02 AM, Chas. Owens wrote:
On Wed, Apr 15, 2009 at 09:38, wrote:
What's the easy way to calculate a webpage's downloading time?
(not only the page, but all the elements in this page, like images,
JS, css etc).
For example, I want to get a function:
my $dl_time = fetch_a_page("www.yahoo.com");
A page's download time will be different from different machines
on the net. You are better off figuring out how much data needs
etc. files). If some of this data is can be cached (such as an
external CSS file that all of the HTML uses) you will want to
create two sizes: first fetch, and subsequent fetches. Once you
have the total size you can calculate the download times for a
variety of download speeds.
If this is someone else's page you can probably fetch each the
page with LWP::Simple, then parse it with HTML::Parser,
and then download each of the items that would normally be
Get the file sizes and add them all up.
designed to do just this. There's no need to reinvent the wheel by
trying to cobble something out of LWP::Simple and HTML::Parser
The real difficulty, as I see it, is defining what you men by "download time."
Raw transfer time is simple to calculate, as Chas. has laid out: (KB *
8)/Kbps = s, where 'KB' is download size in kilobytes, 'Kbps' is
download speed in kilobits/second, and 's' is seconds. If all you want
it raw transfer times, the 'ab' (Apache Benchmark) tool that ships
with Apache is useful, too. It's called Apache Benchmark, but it will
happily flood just about any web server. It's also built on LWP, so
taking a look at the code can be useful, even if you decide to go your
Most of the time, though, when people talk about the download speed of
a web page, they're really talking about page load time. That is, how
long it takes a page to show up in an end user's browser. Page load
times are only loosely related to actual download speeds. Once you
cases--the time it takes to execute and display the scripts is
normally several orders of magnitude longer than the time it takes to
actually transfer them.
This email and attachment(s): [ ] blogable; [ x ] ask first; [ ]
private and confidential
daggerquill [at] gmail [dot] comhttp://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org
values of β will give rise to dom!