If the page you're loading is trivial (i.e., has no external style sheets or java files, no frames, or no images), your script will more or less work, though you're better off using time() instead of gettimeofday().

Most pages of interest aren't trivial, which means that after loading the base page, you need to parse it to find style sheets, frames, images, etc., so that you can load the additional components. This isn't a trivial exercise, particularly if the images are getting loaded by way of JavaScript (say, for rollovers), or via a style sheet. Simulating a browser can take a lot of work; you can sink a lot time into parsing JavaScript and CSS.

To further complicate things, there's caching and session "keep-alive" behavior to emulate.

And if you want to get a really accurate read on how long it takes to read a page, you have to pull out the big guns, and analyze packet traces. Probably more than you need, but it's insightful to do at least once.

So, how accurate a timing do you need?


Update: And if you're counting bytes, don't forget to count both the HTTP header and the TCP/IP header. It's surprisingly expensive, in terms of packet and data exchanged, to verify that a .GIF you have cached locally hasn't changed.


In reply to Re: Timing Web Page Requests by dws
in thread Timing Web Page Requests by insensate

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



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.