Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Re: Re: Bandwidth Testing

by Preceptor (Deacon)
on Aug 27, 2003 at 08:18 UTC ( [id://286976]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Bandwidth Testing
in thread Bandwidth Testing

OK, here's an example that seems to work. Not very pretty, I know :)
Accuracy of this test will increase with larger data sizes, since then you're reducing the percentage overhead introduced by server load, general cgi speed etc.
Seems to work with my quick testing, but YMMV.

(Oh and I had to retype this a couple of times, since the textbox likes to clear whenever I hit 'ESC'. Damn those 'vi' fingers)
#!/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
    Thanks so much you're a life saver I will test thisout today and let you know how things go.
Re: Re: Re: Re: Bandwidth Testing
by sunadmn (Curate) on Aug 27, 2003 at 18:45 UTC
    Quick question for you did you have to do anything special to get this to run correctly?? I am getting a print out that says "please invoke as /cgi-bin/speed_test.cgi?data_size=100 . Does this mean anything to you?? Here is my basic HTML for testing:
    <form name="form1" method="get" action="/cgi-bin/speed_test.cgi"> <input type="submit" name="Submit" value="Start"> </form>
      It means that you need a field in the cgi for 'data_size'.
      I'd suggest adding (iirc):
      <INPUT TYPE="HIDDEN" NAME="data_size" VALUE=100>
      in your form (could be wrong there).
      Basically, you're looking for a URL that looks something like:
      http://www.myserver.net/cgi-bin/speed_test.cgi?data_size=100
      You could always hardcode the data size though, depending on what suits you.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://286976]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-25 15:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found