summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-11-23 18:55:54 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-12-01 03:10:34 -0500
commitc2cb5e9a72cc97c2ad16217813f5826782541afd (patch)
tree502fd351cd472564ce7d0f68adaafffdb9700407
parent0833ad5516738ebd65907cad17a383da9e3bded9 (diff)
downloadhaskell-c2cb5e9a72cc97c2ad16217813f5826782541afd.tar.gz
testsuite: Print geometric mean of stat metrics
As suggested in #20733.
-rw-r--r--testsuite/driver/runtests.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/testsuite/driver/runtests.py b/testsuite/driver/runtests.py
index eff240fc78..47d3324a82 100644
--- a/testsuite/driver/runtests.py
+++ b/testsuite/driver/runtests.py
@@ -9,11 +9,13 @@ import signal
import sys
import os
import io
+import operator
import shutil
import tempfile
import time
import re
import traceback
+from functools import reduce
from pathlib import Path
# We don't actually need subprocess in runtests.py, but:
@@ -361,6 +363,9 @@ def cleanup_and_exit(exitcode):
shutil.rmtree(tempdir, ignore_errors=True)
exit(exitcode)
+def geometric_mean(xs: List[float]) -> float:
+ return reduce(operator.mul, xs)**(1. / len(xs))
+
def tabulate_metrics(metrics: List[PerfMetric]) -> None:
abbrevLen = get_abbrev_hash_length()
hasBaseline = any([x.baseline is not None for x in metrics])
@@ -399,6 +404,15 @@ def tabulate_metrics(metrics: List[PerfMetric]) -> None:
"{}".format(x.change.hint())
)) for x in sorted(metrics, key =
lambda m: (m.stat.test, m.stat.way, m.stat.metric))]
+ geoMean = geometric_mean([
+ x.stat.value / x.baseline.perfStat.value
+ for x in metrics
+ if x.baseline is not None
+ ])
+ dataRows += [
+ row(("", "", "", "", "", "", "", "")),
+ row(("geo. mean", "", "", "", "", "", "{:+4.1f}%".format(100*(geoMean-1)), ""))
+ ]
print_table(headerRows, dataRows, 1)
print("")
if hasBaseline: