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";
|