App-SpeedTest
view release on metacpan or search on metacpan
lib/App/SpeedTest.pm view on Meta::CPAN
#!/usr/bin/perl
package App::SpeedTest;
use strict;
use warnings;
our $VERSION = "0.31";
1;
__END__
=encoding UTF-8
=head1 NAME
App::SpeedTest - Command-line interface to speedtest.net
=head1 SYNOPSIS
$ speedtest [ --no-geo | --country=NL ] [ --list | --ping ] [ options ]
$ speedtest --list
$ speedtest --ping --country=BE
$ speedtest
$ speedtest -s 4358
$ speedtest --url=http://ookla.extraip.net
$ speedtest -q --no-download
$ speedtest -Q --no-upload
=head1 DESCRIPTION
The provided perl script is a command-line interface to the
L<speedtest.net|http://www.speedtest.net/> infrastructure so that
flash is not required
It was written to feature the functionality that speedtest.net offers
without the overhead of flash or java and the need of a browser.
=head1 Raison-d'être
The tool is there to give you a quick indication of the achievable
throughput of your current network. That can drop dramatically if
you are behind (several) firewalls or badly configured networks (or
network parts like switches, hubs and routers).
It was inspired by L<speedtest-cli|https://github.com/sivel/speedtest-cli>,
a project written in python. But I neither like python, nor did I like the
default behavior of that script. I also think it does not take the right
decisions in choosing the server based on distance instead of speed. That
B<does> matter if one has fiber lines. I prefer speed over distance.
=head1 Command-line Arguments
X<CLIA>
=over 2
=item -? | --help
X<-?>
X<--help>
Show all available options and then exit.
=item -V | --version
X<-V>
X<--version>
Show program version and exit.
=item --man
X<--man>
Show the builtin manual using C<pod2man> and C<nroff>.
=item --info
X<--info>
Show the builtin manual using C<pod2text>.
=item -v[#] | --verbose[=#]
X<-v>
X<--version>
Set verbose level. Default value is 1. A plain -v without value will set
the level to 2.
=item --simple
X<--simple>
lib/App/SpeedTest.pm view on Meta::CPAN
X<-U>
X<--skip-undef>
Skip reporting measurements that have no speed recordings at all.
The default is to report these as C<0.00> .. C<999999999.999>.
=item -P | --prtg
X<-P>
X<--prtg>
Generate the measurements in XML suited for PRTG
$ speedtest -P
<?xml version="1.0" encoding="UTF-8" ?>
<prtg>
<text>Testing from My ISP (10.20.30.40)</text>
<result>
<channel>Ping</channel>
<customUnit>ms</customUnit>
<float>1</float>
<value>56.40</value>
</result>
<result>
<channel>Download</channel>
<customUnit>Mbit/s</customUnit>
<float>1</float>
<value>38.34</value>
</result>
<result>
<channel>Upload</channel>
<customUnit>Mbit/s</customUnit>
<float>1</float>
<value>35.89</value>
</result>
</prtg>
=item --url[=XXX]
X<--url>
With no value, show server url in list
With value, use specific server url: do not scan available servers
=item --ip
X<--ip>
Show IP for server
=item -T[#] | --try[=#]
X<-T>
X<--try>
Use the top # (based on lowest latency or shortest distance) from the list
to do all required tests.
$ speedtest -T3 -c NL -Q2
Testing for 80.x.y.z : XS4ALL Internet BV (NL)
Using 13218: 26.52 km 25 ms XS4ALL Internet BV
Test download .. Download 31.807 Mbit/s
Test upload .. Upload 86.587 Mbit/s
Using 15850: 26.09 km 25 ms QTS Data Centers
Test download .. Download 80.763 Mbit/s
Test upload .. Upload 77.122 Mbit/s
Using 11365: 26.09 km 27 ms Vancis
Test download .. Download 106.022 Mbit/s
Test upload .. Upload 82.891 Mbit/s
Rank 01: Server: 11365 26.09 km 27 ms, DL: 106.022 UL: 82.891
Rank 02: Server: 15850 26.09 km 25 ms, DL: 80.763 UL: 77.122
Rank 03: Server: 13218 26.52 km 25 ms, DL: 31.807 UL: 86.587
$ speedtest -1v0 -T5
DL: 200.014 Mbit/s, UL: 159.347 Mbit/s, SRV: 13218
DL: 203.599 Mbit/s, UL: 166.247 Mbit/s, SRV: 15850
DL: 207.249 Mbit/s, UL: 134.957 Mbit/s, SRV: 11365
DL: 195.490 Mbit/s, UL: 172.109 Mbit/s, SRV: 5972
DL: 179.413 Mbit/s, UL: 160.309 Mbit/s, SRV: 2042
Rank 01: Server: 15850 26.09 km 30 ms, DL: 203.599 UL: 166.247
Rank 02: Server: 5972 26.09 km 32 ms, DL: 195.490 UL: 172.109
Rank 03: Server: 13218 26.52 km 23 ms, DL: 200.014 UL: 159.347
Rank 04: Server: 11365 26.09 km 31 ms, DL: 207.249 UL: 134.957
Rank 05: Server: 2042 51.41 km 33 ms, DL: 179.413 UL: 160.309
=item -s# | --server=# | --server=filename
X<-s>
X<--server>
Specify the ID of the server to test against. This ID can be taken from the
output of L</--list> or L</--ping>. Using this option prevents fetching the
complete server list and calculation of distances. It also enables you to
always test against the same server.
$ speedtest -1s4358
Testing for 80.x.y.z : XS4ALL Internet BV ()
Using 4358: 52.33 km 64 ms KPN
Test download ........................................Download: 92.633 Mbit/s
Test upload ........................................Upload: 92.552 Mbit/s
DL: 92.633 Mbit/s, UL: 92.552 Mbit/s
This argument may be repeated to test against multile servers, more or less
like specifying your own top x (as with C<-T>).
$ speedtest -s 22400 -s 1208 -s 13218
Testing for 185.x.y.z : Freedom Internet BV ()
Using 13218: 80.15 km 32 ms XS4ALL Internet BV
Test download ........................................Download 66.833 Mbit/s
Test upload ........................................Upload 173.317 Mbit/s
Using 1208: 51.19 km 37 ms Qweb | Full-Service Hosting
Test download ........................................Download 52.077 Mbit/s
Test upload ........................................Upload 195.833 Mbit/s
Using 22400: 80.15 km 46 ms Usenet.Farm
Test download ........................................Download 96.341 Mbit/s
Test upload ........................................Upload 203.306 Mbit/s
Rank 01: Server: 22400 80.15 km 46 ms, DL: 96.341 UL: 203.306
Rank 02: Server: 1208 51.19 km 37 ms, DL: 52.077 UL: 195.833
Rank 03: Server: 13218 80.15 km 32 ms, DL: 66.833 UL: 173.317
If you pass a filename, it is expected to reflect a server-like structure as
received from the speedtest server-list, possibly completed with upload- and
download URL's. You can only pass one filename not consisting of all digits.
If you do, all remaining C<-s> arguments are ignored.
{ cc => "NL",
country => "Netherlands",
host => "unlisted.host.amsterdam:8080",
id => 9999,
lat => "52.37316",
lon => "4.89122",
name => "Amsterdam",
ping => 20.0,
sponsor => "Dam tot Damloop",
url => "http://unlisted.host.amsterdam/speedtest/speedtest/upload.php",
url2 => "http://unlisted.host.amsterdam/speedtest/speedtest/upload.php",
dl_list => [
"http://unlisted.host.amsterdam/files/128.bin",
"http://unlisted.host.amsterdam/files/256.bin",
# 40 URL's pointing to files in increasing size
"http://unlisted.host.amsterdam/files/2G.bin",
],
ul_list => [
# 40 URL's
],
}
=item -t# | --timeout=#
X<-t>
X<--timeout>
Specify the maximum timeout in seconds.
=item -d | --download
X<-d>
X<--download>
Run the download tests. This is default unless L</--upload> is passed.
=item -u | --upload
X<-u>
X<--upload>
Run the upload tests. This is default unless L</--download> is passed.
=item -q[#] | --quick[=#] | --fast[=#]
X<-q>
X<--quick>
X<--fast>
Don't run the full test. The default test runs 40 tests, sorting on
increasing test size (and thus test duration). Long(er) tests may take
too long on slow connections without adding value. The default value
for C<-q> is 20 but any value between 1 and 40 is allowed.
=item -Q[#] | --realquick[=#]
X<-Q>
X<--realquick>
Don't run the full test. The default test runs 40 tests, sorting on
increasing test size (and thus test duration). Long(er) tests may take
too long on slow connections without adding value. The default value
for C<-Q> is 10 but any value between 1 and 40 is allowed.
=item -mXX | --mini=XX
X<-m>
X<--mini>
Run the speedtest on a speedtest mini server.
=item --source=XX
NYI - mentioned for speedtest-cli compatibility
=back
=head1 EXAMPLES
See L</SYNOPSIS> and L<Command-line arguments|/CLIA>
=head1 DIAGNOSTICS
...
=head1 BUGS and CAVEATS
Due to language implementation, it may report speeds that are not
consistent with the speeds reported by the web interface or other
speed-test tools. Likewise for reported latencies, which are not
to be compared to those reported by tools like ping.
=head1 TODO
=over 2
=item Improve documentation
What did I miss?
=item Enable alternative XML parsers
XML::Simple is not the recommended XML parser, but it sufficed on
startup. All other API's are more complex.
( run in 1.219 second using v1.01-cache-2.11-cpan-b16cb0d3907 )