pull from samba
[tridge/junkcode.git] / expected_throughput.pl
1 #!/usr/bin/perl
2 # work out the expected throughput of a network filesystem without overlapped
3 # reads
4 # tridge@samba.org January 2008
5
6 # Note: to get network latency, try ping -s 64 <DEST>
7
8 use strict;
9
10 if ($#ARGV < 3) {
11         print "
12 Usage: expected_throughput.pl <server_throughput> <network_throughput> <network_latency> <io_size>
13   Latencies in Microseconds
14   Throughputs in MByte/sec
15   IO Size in Bytes
16 ";
17         exit(0);
18 }
19
20 my $server_throughput = shift;
21 my $network_throughput = shift;
22 my $network_latency = shift;
23 my $io_size = shift;
24
25 # scale to seconds and bytes
26 $server_throughput *= 1.0e6;
27 $network_throughput *= 1.0e6;
28 $network_latency *= 1.0e-6;
29
30 my $total_latency = $network_latency;
31
32 $total_latency += (1.0/$server_throughput) * $io_size;
33 $total_latency += (1.0/$network_throughput) * $io_size;
34
35 my $expected_throughput = $io_size/$total_latency;
36
37 printf "With server throughput  :  %7.1f MByte/s\n", $server_throughput * 1.0e-6;
38 printf "With network throughput :  %7.1f MByte/s\n", $network_throughput * 1.0e-6;
39 printf "With network latency    :  %7.1f usec\n", $network_latency * 1.0e6;
40 printf "With network IO size    :  %7.0f bytes\n", $io_size;
41 printf ">> Expected throughput is %.2f MByte/sec\n", $expected_throughput * 1.0e-6;
42