in reply to CGI speed: one script versus many modules

So I lay in bed last night after posting this and I guess putting my question out there made me think more about doing timing analysis. I browse through the perl cookbook often and wasn't there a module on hi-res timing? And I know there's a web user agent module...

So, I got up browsed through the cookbook and yes, what I thought would be non-trivial was actually kind of trivial:

#!/usr/local/bin/perl use strict; use LWP::Simple; use Time::HiRes; my $totalTime = 0; my $i; for ($i=0; $i < 20; $i++) { my $before = Time::HiRes::gettimeofday(); if ( !defined( my $content = LWP::Simple::get('http://chicodigita +l.com/cgi-bin/temp/webtool.cgi'))) { print "failed get\n"; } my $elapsed = Time::HiRes::gettimeofday() - $before; print "get $i in $elapsed seconds.\n"; $totalTime = $totalTime + $elapsed; } $totalTime = $totalTime / 20; print "Average response time for 20 requests was: $totalTime seconds.\ +n";

Hey, it works! Well, it's more a measure of the internet speed, but averaged, at least that would be a speed difference as perceived by the user. So I'll keep you posted on my finding here.

Thank you perlmonks, for making me think.

-alan