[pypy-commit] benchmarks default: Display the geometric averages

arigo pypy.commits at gmail.com
Wed Mar 8 03:29:21 EST 2017


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r370:9dfde57979c7
Date: 2017-03-08 09:29 +0100
http://bitbucket.org/pypy/benchmarks/changeset/9dfde57979c7/

Log:	Display the geometric averages

diff --git a/display_local.py b/display_local.py
--- a/display_local.py
+++ b/display_local.py
@@ -16,6 +16,7 @@
 
 import sys
 import json
+import math
 from unladen_swallow import perf
 
 
@@ -76,22 +77,42 @@
     row.append('')
     return raw1
 
+def geometric_average(lst):
+    return math.exp(sum(math.log(t) for t in lst) / len(lst))
+
 def display(times1, times2=None):
     if times2 is None:
         times2 = {}
     all_names = sorted(set(times1) | set(times2))
-    table = [['BENCHMARK', '   ', 'min', ' ', 'avg', ' ', 'stddev', '  ',
+    table = [[],
+             ['BENCHMARK', '   ', 'min', ' ', 'avg', ' ', 'stddev', '  ',
               'min', ' ', 'avg', ' ', 'stddev', '  ',
               'diff']]
     RIGHT_ALIGN = '\x00'
 
+    l_avg1 = []
+    l_avg2 = []
     for name in all_names:
         row = [name, '']
         table.append(row)
         raw1 = _report(row, times1.get(name))
         raw2 = _report(row, times2.get(name))
         if raw1 and raw2:
-            row.append(perf.TimeDelta(perf.avg(raw1), perf.avg(raw2)))
+            t_avg1 = perf.avg(raw1)
+            t_avg2 = perf.avg(raw2)
+            row.append(perf.TimeDelta(t_avg1, t_avg2))
+            l_avg1.append(t_avg1)
+            l_avg2.append(t_avg2)
+
+    table.append([])
+    if len(l_avg1) == len(all_names):
+        g_avg1 = geometric_average(l_avg1)
+        g_avg2 = geometric_average(l_avg2)
+        row = ['GEOM AVG', '',
+               '', '', str(round(g_avg1, 3)), '', '', '',
+               '', '', str(round(g_avg2, 3)), '', '', '',
+               perf.TimeDelta(g_avg1, g_avg2)]
+        table.append(row)
 
     lengths = []
     for row in table:


More information about the pypy-commit mailing list