jablonka.czprosek.czf

banderdyn

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

 

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 
19print "Content-type: text/html\n\n";
20 
21print "<HTML><HEAD><META HTTP-EQUIV=Pragma CONTENT=no-cache></HEAD><BODY>\n"; # nocache!
22 
23$kb = 1024;
24@nkbp = (10,20,70,150,300,218);
25$nkb = 0;
26$lnkbp = $#nkbp;
27 
28@pism = ("aa","bb","cc","dd","ee","ff");
29 
30$svrtimeout = 30; # httpd server timeout in seconds
31 
32$testtime = 10; # maximum test time
33 
34$lospd = $nkbp[0]/$svrtimeout;
35 
36#print "<CENTER>\n";
37printf "If no speed information is given then either your connection is too slow (< %1.2f kiB/s) or you are experiencing signal dropouts. <br>\n", $lospd;
38 
39print "Sending";
40 
41 
42$tm2 = $tm1 = time;
43 
44for ($ii = 0; $ii <= $lnkbp; $ii++) {
45 if ( ($tm2-$tm1) < $testtime )
46 {
47 for ($f = 1; $f <= $nkbp[$ii]; $f++) {
48 print "<!--";
49 for ($g = 1; $g <= ($kb/2-5) ; $g++) { print "$pism[$ii]"; }
50 print "-->. \n";
51 }
52 $tm2 = time;
53 $nkb = $nkb + $nkbp[$ii];
54 print "$nkb"."kiB";
55 }
56}
57 
58print "<br>\n";
59 
60$adresa = "$ENV{'REMOTE_ADDR'}";
61$server = "$ENV{'SERVER_NAME'}";
62 
63print "\n<P>";
64$time = ($tm2-$tm1);
65printf "Sent $nkb kiB from $server to $adresa in $time seconds<br>\n";
66print "Approximate download bandwidth speed of your connection is: ";
67# to not divide accidentaly by zero we accept inacurrancy of 0.001s
68$speed = $nkb*$kb/($time+0.001);
69$speedkb = $speed/$kb;
70$speedkbps = 8*$speed/$kb;
71printf "%.2f B/s = %.2f kiB/s = %.2f kib/s\n", $speed, $speedkb, $speedkbps;
72$date = `date`;
73print "<BR>$date\n<BR>";
74print "<A HREF=\"http://bbs.cvut.cz/~covex/czfree/index.html\#bander\">BanderDyn speed test</A>\n";
75 
76#print "</CENTER>\n";
77print "</BODY></HTML>";

Powered by WebSVN 2.2.1