]> git.sesse.net Git - bursty/commitdiff
Add a simple Perl script to tally statistics (probably requires more polish).
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 28 May 2012 13:10:40 +0000 (15:10 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 28 May 2012 13:10:40 +0000 (15:10 +0200)
summarize.pl [new file with mode: 0755]

diff --git a/summarize.pl b/summarize.pl
new file mode 100755 (executable)
index 0000000..545fa0e
--- /dev/null
@@ -0,0 +1,27 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+
+my %buckets = ();
+
+while (<>) {
+       chomp;
+       my (@x) = split /\s+/, $_;
+
+       my $num_packets = scalar @x;
+       my $num_drops = grep { /\*/ } @x;
+
+       $buckets{$num_packets}->{'num_bursts'}++;
+       $buckets{$num_packets}->{'num_drops'} += $num_drops;
+       if ($num_drops > 0) {
+               $buckets{$num_packets}->{'bursts_with_drops'}++;
+       }
+}
+
+for my $n (sort { $a <=> $b } keys %buckets) {
+       my $drop_rate = $buckets{$n}->{'num_drops'} / ($n * $buckets{$n}->{'num_bursts'});
+       my $drop_event_rate = $buckets{$n}->{'num_drops'} / ($n * $buckets{$n}->{'num_bursts'});
+       printf "%3d: drop_rate %.5f  drop_event_rate %.5f\n",
+               $n, $drop_rate, $drop_event_rate; 
+}