jablonka.czprosek.czf

banderdyn

Subversion Repositories:
[/] [banderdyn.cgi] - Blame information for rev 2

 

Line No. Rev Author Line
11simandl#!/usr/bin/perl
2#
3##############################################
4# BanderDyn
5##############################################
6# Simple script for measuring download
7# speed, with some dynamical ability
8# to end up as soon as 10s are crossed.
9#
10# It's time precision is 1s -
11# we only relay on system time ability
12# and are not using require 'sys/syscall.ph';
13# http://www.perldoc.com/perl5.8.0/pod/perlfaq8.html
14#
15# Bander, maintenance: Adam Pribyl, covex@ahoj.fsik.cvut.cz
16# Dyn: Petr Simandl, www.simandl.cz
17###############################################
18 
192simandluse Time::HiRes;
20 
211simandlprint "Content-type: text/html\n\n";
22 
232simandlprint "<HTML><HEAD><META HTTP-EQUIV=Pragma CONTENT=no-cache>";
24print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"></HEAD><BODY>\n"; # nocache!
251simandl 
262simandl$kb = 50*1024;
27@nkbp = (10,20,70,100,300,500);
281simandl$nkb = 0;
29$lnkbp = $#nkbp;
30 
312simandl@pism = ("aaaaaaaaaa","bbbbbbbbbb","cccccccccc","dddddddddd","eeeeeeeeee","ffffffffff");
321simandl 
33$svrtimeout = 30; # httpd server timeout in seconds
34 
35$testtime = 10; # maximum test time
36 
37$lospd = $nkbp[0]/$svrtimeout;
38 
392simandlprint "<CENTER>\n";
40printf "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;
411simandl 
422simandlprint "OdeslĂĄno";
431simandl 
442simandl$tm2 = 0;
45$tm1 = [ Time::HiRes::gettimeofday( ) ];
461simandl 
47for ($ii = 0; $ii <= $lnkbp; $ii++) {
482simandl if ( $tm2 < $testtime )
491simandl {
502simandl $numkb=$nkbp[$ii];
51 for ($f = 1; $f <= $numkb; $f++) {
521simandl print "<!--";
532simandl for ($g = 1; $g <= (($kb-10)/50) ; $g++) { print "aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeee"; }
541simandl print "-->. \n";
55 }
562simandl $tm2 = Time::HiRes::tv_interval( $tm1 );
571simandl $nkb = $nkb + $nkbp[$ii];
582simandl printf "%.2f MiB", $nkb * $kb/1000000;
591simandl }
60}
61 
62print "<br>\n";
63 
64$adresa = "$ENV{'REMOTE_ADDR'}";
65$server = "$ENV{'SERVER_NAME'}";
66 
67print "\n<P>";
682simandl$time = ($tm2);
69$numMb = $nkb * $kb/1000024;
70printf "OdeslĂĄno %.2f MiB ze serveru $server na IP adresu $adresa za %.2f sekund<br />\n", $numMb, $time;
71print "Přibližná rychlost stahování Vašeho připojení je: ";
72$speed = $nkb*$kb/$tm2;
73$speedkb = $speed/1024;
74$speedkbps = 8*$speed/1024;
75printf "%.2f B/s = %.2f kiB/s = %.2f Mib/s\n", $speed, $speedkb, $speedkbps/1000;
76 
77printf "<h3>VaĹĄe rychlost stahovĂĄnĂ­ ze serveru $server je %.2f MegabitĹŻ za sekundu</h3>\n", $speedkbps/1000;
781simandl$date = `date`;
792simandlprint "$date\n<BR />";
80print "<A HREF=\"http://bbs.cvut.cz/~covex/czfree/index.html\#bander\">Bander speed test</A>\n";
811simandl 
822simandlprint "</center></BODY></HTML>";

Powered by WebSVN 2.2.1