To measure throughput use LWP or Net::FTP and measure
the time (using
Time::HiRes for
greater accuracy) it takes to push a large
chunk of data across. Divide the
data size by the elapsed time
and you will have a usable aproximation of
end-to-end application-layer
throughput.
use LWP::Simple;
use Time::HiRes qw( gettimeofday tv_interval );
my $t0 = [gettimeofday];
my $d=get('http://www.perlmonks.org');
my $elapsed=tv_interval ( $t0, [gettimeofday]);
my $throughput=length($d)/$elapsed;
print "throughput=$throughput Bytes per second\n";
Another (more accurate) measurement could be
gathered by spawning off several such "data pusher" processes
in parallel. Then use raw network IO stats (gathered by SNMP or however
you want) to determine the throughput during the period
of the test.
You can get latency by using a
Time::HiRes timer around Net::Ping.
My example below takes only a single ping, for real use
you'd probably want to take multiple tests and average them.
use Time::HiRes qw( gettimeofday tv_interval );
use Net::Ping;
my $p = Net::Ping->new("icmp");
my $t0 = [gettimeofday];
$p->ping('127.0.0.1',5);
my $elapsed=tv_interval ( $t0, [gettimeofday]);
print "latency=$elapsed\n";
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.