From c906e5919f7730515669f9847c8a61585a8eea6b Mon Sep 17 00:00:00 2001 From: John Denker Date: Tue, 17 Jul 2012 15:17:54 -0700 Subject: simple thing to calculate percentiles --- tools/percentile.pl | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 tools/percentile.pl diff --git a/tools/percentile.pl b/tools/percentile.pl new file mode 100755 index 0000000..37e6068 --- /dev/null +++ b/tools/percentile.pl @@ -0,0 +1,39 @@ +#! /usr/bin/perl -w + +use strict; +use Symbol; + +main: { + my @buf = (); + my $running = 0; + my $file = $ARGV[0] + || die "usage: $0 filename\n"; + my $inch = Symbol::gensym; + open($inch, '<', $file) + || die "Could not open input file '$file'\n"; + while (my $line = <$inch>) { + chomp $line; + push @buf, $line; + my @stuff = split(' ', $line); + $running += $stuff[0]; + } + close $inch; + my $total = $running; + $running = 0; + open($inch, '<', $file) + || die "Could not reopen input file '$file'\n"; + while (my $line = <$inch>) { + chomp $line; + push @buf, $line; + my @stuff = split(' ', $line); + $running += $stuff[0]; + my $frac = 100 * $running / $total; + if (0) { + printf("%5d %5d %5.1f %s\n", + $stuff[0], $running, $frac, $stuff[1]); + } else { + print 'blacklist_from *@', $stuff[1], "\n"; + } + } + +} -- cgit v1.2.3