banderdyn |
Subversion Repositories: |
Compare with Previous - Blame - Download
#!/usr/bin/perl
#
##############################################
# BanderDyn
##############################################
# Simple script for measuring download
# speed, with some dynamical ability
# to end up as soon as 10s are crossed.
#
# It's time precision is 1s -
# we only relay on system time ability
# and are not using require 'sys/syscall.ph';
# http://www.perldoc.com/perl5.8.0/pod/perlfaq8.html
#
# Bander, maintenance: Adam Pribyl, covex@ahoj.fsik.cvut.cz
# Dyn: Petr Simandl, www.simandl.cz
###############################################
use Time::HiRes;
print "Content-type: text/html\n\n";
print "<HTML><HEAD><META HTTP-EQUIV=Pragma CONTENT=no-cache>";
print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"></HEAD><BODY>\n"; # nocache!
$kb = 50*1024;
@nkbp = (10,20,70,100,300,500);
$nkb = 0;
$lnkbp = $#nkbp;
@pism = ("aaaaaaaaaa","bbbbbbbbbb","cccccccccc","dddddddddd","eeeeeeeeee","ffffffffff");
$svrtimeout = 30; # httpd server timeout in seconds
$testtime = 10; # maximum test time
$lospd = $nkbp[0]/$svrtimeout;
print "<CENTER>\n";
printf "Pokud se VĂĄm po chvilce nezobrazĂ namÄĹenĂĄ rychlost, tak mĂĄte pomalĂŠ pĹipojenĂ (< %1.2f kiB/s) a nebo zaruĹĄenĂŠ pĹipojenĂ. <br>\n", $lospd;
print "OdeslĂĄno";
$tm2 = 0;
$tm1 = [ Time::HiRes::gettimeofday( ) ];
for ($ii = 0; $ii <= $lnkbp; $ii++) {
if ( $tm2 < $testtime )
{
$numkb=$nkbp[$ii];
for ($f = 1; $f <= $numkb; $f++) {
print "<!--";
for ($g = 1; $g <= (($kb-10)/50) ; $g++) { print "aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeee"; }
print "-->. \n";
}
$tm2 = Time::HiRes::tv_interval( $tm1 );
$nkb = $nkb + $nkbp[$ii];
printf "%.2f MiB", $nkb * $kb/1000000;
}
}
print "<br>\n";
$adresa = "$ENV{'REMOTE_ADDR'}";
$server = "$ENV{'SERVER_NAME'}";
print "\n<P>";
$time = ($tm2);
$numMb = $nkb * $kb/1000024;
printf "OdeslĂĄno %.2f MiB ze serveru $server na IP adresu $adresa za %.2f sekund<br />\n", $numMb, $time;
print "PĹibliĹžnĂĄ rychlost stahovĂĄnĂ VaĹĄeho pĹipojenĂ je: ";
$speed = $nkb*$kb/$tm2;
$speedkb = $speed/1024;
$speedkbps = 8*$speed/1024;
printf "%.2f B/s = %.2f kiB/s = %.2f Mib/s\n", $speed, $speedkb, $speedkbps/1000;
printf "<h3>VaĹĄe rychlost stahovĂĄnĂ ze serveru $server je %.2f MegabitĹŻ za sekundu</h3>\n", $speedkbps/1000;
$date = `date`;
print "$date\n<BR />";
print "<A HREF=\"http://bbs.cvut.cz/~covex/czfree/index.html\#bander\">Bander speed test</A>\n";
print "</center></BODY></HTML>";