]> mj.ucw.cz Git - netgrind.git/blob - post/graph-http-spect-wait
More tools.
[netgrind.git] / post / graph-http-spect-wait
1 #!/usr/bin/perl
2 # Draw spectrum of HTTP transaction lengths from netgrind output
3 # (c) 2003 Martin Mares <mj@ucw.cz>, GPL'ed
4
5 use strict;
6 use warnings;
7 use POSIX;
8
9 my @k = ( 0, 0.25, 0.5, 1, 2, 4, 8, 16, 32, 64, 1000000000 );
10 my @v1 = map { 0 } @k;
11 my @v2 = map { 0 } @k;
12
13 while (<>) {
14         chomp;
15         /^#/ && next;
16         my ($t1, $t2, $src, $dst, $ffor, $result, $cache, $queue, $length, $totaltime, $waittime, $ctype, $method, $url) = split /\s+/;
17         if ($result =~ /^\d+$/) {
18                 my $i = 0;
19                 while ($totaltime >= $k[$i+1]) {
20                         $i++;
21                 }
22                 $v1[$i]++;
23                 $i = 0;
24                 while ($waittime >= $k[$i+1]) {
25                         $i++;
26                 }
27                 $v2[$i]++;
28         }
29 }
30
31 my $datafile = "gp.tmp";
32 open D, ">$datafile" or die;
33 for(my $i=0; $i<$#k; $i++) {
34         print D $k[$i], "\t", $v1[$i], "\t", $v2[$i], "\n";
35 }
36 close D;
37
38 open GP, "|gnuplot" or die;
39 print GP <<EOF
40 set terminal png
41 set grid
42 set style data boxes
43 set title "HTTP Transactions: Length Histogram"
44 set xlabel "Delay in seconds"
45 set ylabel "Number of transactions"
46 set logscale x 2
47 plot    "$datafile" using 1:2 title "Total time", \\
48         "$datafile" using 1:3 title "Wait time"
49 EOF
50 ;
51 close GP;