summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-07-17 15:17:54 -0700
committerJohn Denker <jsd@av8n.com>2012-07-29 15:32:33 -0700
commitc906e5919f7730515669f9847c8a61585a8eea6b (patch)
tree2c5afb9b0255372035d433151e1658309a096993
parent58b88adfe892e5a327148ad7a991d453ba231607 (diff)
simple thing to calculate percentiles
-rwxr-xr-xtools/percentile.pl39
1 files changed, 39 insertions, 0 deletions
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";
+ }
+ }
+
+}