]> mj.ucw.cz Git - netgrind.git/commitdiff
More tools.
authorMartin Mares <mj@ucw.cz>
Sat, 21 Jun 2003 08:55:46 +0000 (08:55 +0000)
committerMartin Mares <mj@ucw.cz>
Sat, 21 Jun 2003 08:55:46 +0000 (08:55 +0000)
post/graph-http-spect-sizes [new file with mode: 0755]
post/graph-http-spect-wait [new file with mode: 0755]
post/http-extract [new file with mode: 0755]

diff --git a/post/graph-http-spect-sizes b/post/graph-http-spect-sizes
new file mode 100755 (executable)
index 0000000..e6cbd47
--- /dev/null
@@ -0,0 +1,44 @@
+#!/usr/bin/perl
+# Draw spectrum of HTTP transaction lengths from netgrind output
+# (c) 2003 Martin Mares <mj@ucw.cz>, GPL'ed
+
+use strict;
+use warnings;
+use POSIX;
+
+my @k = ( 0, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 1000000000 );
+my @v = map { 0 } @k;
+
+while (<>) {
+       chomp;
+       /^#/ && next;
+       my ($t1, $t2, $src, $dst, $ffor, $result, $cache, $queue, $length, $totaltime, $waittime, $ctype, $method, $url) = split /\s+/;
+       if ($result =~ /^\d+$/) {
+               my $i = 0;
+               while ($length >= $k[$i+1]) {
+                       $i++;
+               }
+               $v[$i]++;
+       }
+}
+
+my $datafile = "gp.tmp";
+open D, ">$datafile" or die;
+for(my $i=0; $i<$#k; $i++) {
+       print D $k[$i], "\t", $v[$i], "\n";
+}
+close D;
+
+open GP, "|gnuplot" or die;
+print GP <<EOF
+set terminal png
+set grid
+set style data boxes
+set title "HTTP Transactions: Length Histogram"
+set xlabel "Length in bytes"
+set ylabel "Number of transactions"
+set logscale x 2
+plot   "$datafile" using 1:2 title "Histogram"
+EOF
+;
+close GP;
diff --git a/post/graph-http-spect-wait b/post/graph-http-spect-wait
new file mode 100755 (executable)
index 0000000..00e0e16
--- /dev/null
@@ -0,0 +1,51 @@
+#!/usr/bin/perl
+# Draw spectrum of HTTP transaction lengths from netgrind output
+# (c) 2003 Martin Mares <mj@ucw.cz>, GPL'ed
+
+use strict;
+use warnings;
+use POSIX;
+
+my @k = ( 0, 0.25, 0.5, 1, 2, 4, 8, 16, 32, 64, 1000000000 );
+my @v1 = map { 0 } @k;
+my @v2 = map { 0 } @k;
+
+while (<>) {
+       chomp;
+       /^#/ && next;
+       my ($t1, $t2, $src, $dst, $ffor, $result, $cache, $queue, $length, $totaltime, $waittime, $ctype, $method, $url) = split /\s+/;
+       if ($result =~ /^\d+$/) {
+               my $i = 0;
+               while ($totaltime >= $k[$i+1]) {
+                       $i++;
+               }
+               $v1[$i]++;
+               $i = 0;
+               while ($waittime >= $k[$i+1]) {
+                       $i++;
+               }
+               $v2[$i]++;
+       }
+}
+
+my $datafile = "gp.tmp";
+open D, ">$datafile" or die;
+for(my $i=0; $i<$#k; $i++) {
+       print D $k[$i], "\t", $v1[$i], "\t", $v2[$i], "\n";
+}
+close D;
+
+open GP, "|gnuplot" or die;
+print GP <<EOF
+set terminal png
+set grid
+set style data boxes
+set title "HTTP Transactions: Length Histogram"
+set xlabel "Delay in seconds"
+set ylabel "Number of transactions"
+set logscale x 2
+plot   "$datafile" using 1:2 title "Total time", \\
+       "$datafile" using 1:3 title "Wait time"
+EOF
+;
+close GP;
diff --git a/post/http-extract b/post/http-extract
new file mode 100755 (executable)
index 0000000..aa82168
--- /dev/null
@@ -0,0 +1,18 @@
+#!/usr/bin/perl
+# Extract data from HTTP transactions
+# (c) 2003 Martin Mares <mj@ucw.cz>, GPL'ed
+
+use strict;
+use warnings;
+use POSIX;
+
+1 == @ARGV or die "Usage: http-extract <perl-expression>";
+eval '
+while (<STDIN>) {
+       chomp;
+       /^#/ && next;
+       my ($t1, $t2, $src, $dst, $ffor, $result, $cache, $queue, $length, $totaltime, $waittime, $ctype, $method, $url) = split /\s+/;
+       print ' . $ARGV[0] . ', "\n";
+}
+';
+die "$ARGV[0]: $@" if $@;