summaryrefslogtreecommitdiff
path: root/tools/percentile.pl
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2012-07-17 22:17:54 (GMT)
committerJohn Denker <jsd@av8n.com>2012-07-17 22:17:54 (GMT)
commit5999704e126290b4011d40730d8b85cdd160f5b6 (patch)
tree6069bb8391b973a1753a3af32461ab487c249fce /tools/percentile.pl
parent2400eaeb734f5a80812fdb936626fa9fdcbda115 (diff)
simple thing to calculate percentiles
Diffstat (limited to 'tools/percentile.pl')
-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";
+ }
+ }
+
+}