summaryrefslogtreecommitdiff
path: root/orbsvcs/tests/EC_Multiple/histo.pl
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2010-08-13 15:47:20 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2010-08-13 15:47:20 +0000
commitd86939f8e188671a6226b24e0957d984050c0ed6 (patch)
treee58de7d2e0d317204ee79bd0578e51c93bf58ea8 /orbsvcs/tests/EC_Multiple/histo.pl
parente55d9214407ea472e418f9852cb58dddab0c83f5 (diff)
downloadATCD-d86939f8e188671a6226b24e0957d984050c0ed6.tar.gz
Diffstat (limited to 'orbsvcs/tests/EC_Multiple/histo.pl')
-rwxr-xr-xorbsvcs/tests/EC_Multiple/histo.pl76
1 files changed, 76 insertions, 0 deletions
diff --git a/orbsvcs/tests/EC_Multiple/histo.pl b/orbsvcs/tests/EC_Multiple/histo.pl
new file mode 100755
index 00000000000..dcd13f27320
--- /dev/null
+++ b/orbsvcs/tests/EC_Multiple/histo.pl
@@ -0,0 +1,76 @@
+#
+# $Id$
+#
+# Extract a histogram, minimum, maximum and average from a file,
+# filtering by a given RE.
+#
+
+eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
+ & eval 'exec perl -S $0 $argv:q'
+ if 0;
+
+# The first three lines above let this script run without specifying the
+# full path to perl, as long as it is in the user's PATH.
+# Taken from perlrun man page.
+
+use Getopt::Std;
+
+$opt_k = 'Latency\[LCL,[A-Z]*\]';
+$opt_r = 1;
+
+getopts ('k:r:');
+
+$max = 0;
+$min = 0;
+$sum = 0;
+$sum2 = 0;
+$n = 0;
+%histo = ();
+
+while (<>) {
+ if (!m/^$opt_k/) {
+ next;
+ }
+ chop;
+ @f = split(/:/, $_);
+ if ($n == 0) {
+ $min = $f[1];
+ $max = $f[1];
+ $sum = $f[1];
+ $sum2 = $f[1] * $f[1];
+ $n = 1;
+ } else {
+ if ($min > $f[1]) {
+ $min = $f[1];
+ }
+ if ($max < $f[1]) {
+ $max = $f[1];
+ }
+ $sum += $f[1];
+ $sum2 += $f[1] * $f[1];
+ $n++;
+ }
+ $i = int ($f[1] * $opt_r);
+ $histo{"$i"}++;
+}
+
+print "Latency results for $opt_k:\n";
+$s2 = $sum2 / ($n - 1) - $sum / $n * $sum / ($n - 1);
+if ($s2 >= 0) {
+ $sigma = int(sqrt ( $s2 ));
+} else {
+ print "Error: $sum, $sum2, $n\n";
+ $sigma = $sum2;
+}
+
+print "Min: $min,",
+ " Max: $max,",
+ " Avg: ", int($sum / $n),
+ " Dev: ", $sigma,
+ "\n";
+
+while ( ($key,$value) = each %histo ) {
+ $t = ($key / $opt_r);
+ print $t, " ", 100 * $value / $n, "\n";
+}
+