#!/usr/bin/perl
# testcs.pl by Edward Chow, 2/3/2001
#

use LWP::Simple;
use Time::HiRes qw(usleep gettimeofday tv_interval);

$count = 0;

open(OUT, ">filert_get");
print OUT get "http://gallop.uccs.edu:8888/examples/IncludeTag.jsp";
close(OUT);

for ($i=1; $i<2; $i++) {
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1); $count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1); $count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1); $count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
sleep(1);$count ++;
timeGetUrl ('http://gallop.uccs.edu:8888/examples/IncludeTag.jsp');
}

sub timeGetUrl() {
        my ($url) = @_;

   my $s1;
   my $usec1;
   my $s2;
   my $usec2;
   my $time_diff;

#        $time1 = time;

   ($s1, $usec1) = gettimeofday;

         $doc = get $url;

   ($s2, $usec2) = gettimeofday;
  
         $length= length  $doc;

   $time_diff = ($s2 - $s1) * 1000000 + ($usec2 - $usec1);

        print "get $url size $length in $time_diff microseconds count $count \n";

#        $time2 = time;
#        $period = $time2 - $time1;
#        print "get $url size $length in $period seconds\n";
	
}

