in reply to Re: Re: Bandwidth Testing
in thread Bandwidth Testing
#!/bin/perl use warnings; use strict; use Time::HiRes qw ( gettimeofday ) ; my $data = "E"x1020; #start with using 1k blocks shall we? my %cgi_vars; foreach my $pair ( split ( "&", $ENV{'QUERY_STRING'} ) ) { my ( $var, $val ) = split ("=", $pair); $cgi_vars{$var} = $val; } #cgi headers: print "content-type: text/html\n\n"; #take time my ( $start_seconds, $start_microseconds ) = gettimeofday; print "$start_seconds $start_microseconds<BR/>\n"; #print stuff to thingy if ( $cgi_vars{"data_size"} ) { for ( my $count=0; $count < $cgi_vars{"data_size"}; $count++ ) { print "<!",$data,"->\n"; } } #take time. my ( $end_seconds, $end_microseconds ) = gettimeofday; print "$end_seconds $end_microseconds<BR/>\n"; #compare. my $time_delta = ($end_seconds - $start_seconds) + ( ( $end_microsecon +ds - $start_microseconds) / 1000000); if ( $cgi_vars{"data_size"} ) { print "your data transfer of ", $cgi_vars{"data_size"}, "k took ", $ +time_delta, " seconds<BR/>\n"; print "your bandwidth is ",$cgi_vars{"data_size"} / $time_delta ," k +ilobytes/sec<BR/>\n"; } else { print "please invoke as $ENV{'SCRIPT_NAME'}?data_size=100<BR/> \n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Bandwidth Testing
by sunadmn (Curate) on Aug 27, 2003 at 13:55 UTC | |
|
Re: Re: Re: Re: Bandwidth Testing
by sunadmn (Curate) on Aug 27, 2003 at 18:45 UTC | |
by Preceptor (Deacon) on Aug 27, 2003 at 21:48 UTC |