Update bench_compare to do the comparison using different statistical methods

Review URL: https://codereview.appspot.com/6461110

git-svn-id: http://skia.googlecode.com/svn/trunk@5217 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/bench/bench_compare.py b/bench/bench_compare.py
index c1a1ff9..d853358 100644
--- a/bench/bench_compare.py
+++ b/bench/bench_compare.py
@@ -13,6 +13,12 @@
     print '-o <file> the old bench output file.'
     print '-n <file> the new bench output file.'
     print '-h causes headers to be output.'
+    print '-s <stat> the type of statistical analysis used'
+    print '   Not specifying is the same as -s "avg".'
+    print '  avg: average of all data points'
+    print '  min: minimum of all data points'
+    print '  med: median of all data points'
+    print '  25th: twenty-fifth percentile for all data points'
     print '-f <fieldSpec> which fields to output and in what order.'
     print '   Not specifying is the same as -f "bctondp".'
     print '  b: bench'
@@ -46,7 +52,7 @@
     """Parses command line and writes output."""
     
     try:
-        opts, _ = getopt.getopt(sys.argv[1:], "f:o:n:h")
+        opts, _ = getopt.getopt(sys.argv[1:], "f:o:n:s:h")
     except getopt.GetoptError, err:
         print str(err) 
         usage()
@@ -77,6 +83,7 @@
     header_format = ""
     columns = 'bctondp'
     header = False
+    stat_type = "avg"
     
     for option, value in opts:
         if option == "-o":
@@ -87,6 +94,8 @@
             header = True
         elif option == "-f":
             columns = value
+        elif option == "-s":
+            stat_type = value
         else:
             usage()
             assert False, "unhandled option"
@@ -114,8 +123,8 @@
             , diffp='diffP'
         )
     
-    old_benches = bench_util.parse({}, open(old, 'r'))
-    new_benches = bench_util.parse({}, open(new, 'r'))
+    old_benches = bench_util.parse({}, open(old, 'r'), stat_type)
+    new_benches = bench_util.parse({}, open(new, 'r'), stat_type)
     
     bench_diffs = []
     for old_bench in old_benches: