Skip to content
Snippets Groups Projects
Commit c2cb5e9a authored by Ben Gamari's avatar Ben Gamari Committed by Marge Bot
Browse files

testsuite: Print geometric mean of stat metrics

As suggested in #20733.
parent 0833ad55
No related branches found
No related tags found
No related merge requests found
...@@ -9,11 +9,13 @@ import signal ...@@ -9,11 +9,13 @@ import signal
import sys import sys
import os import os
import io import io
import operator
import shutil import shutil
import tempfile import tempfile
import time import time
import re import re
import traceback import traceback
from functools import reduce
from pathlib import Path from pathlib import Path
# We don't actually need subprocess in runtests.py, but: # We don't actually need subprocess in runtests.py, but:
...@@ -361,6 +363,9 @@ def cleanup_and_exit(exitcode): ...@@ -361,6 +363,9 @@ def cleanup_and_exit(exitcode):
shutil.rmtree(tempdir, ignore_errors=True) shutil.rmtree(tempdir, ignore_errors=True)
exit(exitcode) exit(exitcode)
def geometric_mean(xs: List[float]) -> float:
return reduce(operator.mul, xs)**(1. / len(xs))
def tabulate_metrics(metrics: List[PerfMetric]) -> None: def tabulate_metrics(metrics: List[PerfMetric]) -> None:
abbrevLen = get_abbrev_hash_length() abbrevLen = get_abbrev_hash_length()
hasBaseline = any([x.baseline is not None for x in metrics]) hasBaseline = any([x.baseline is not None for x in metrics])
...@@ -399,6 +404,15 @@ def tabulate_metrics(metrics: List[PerfMetric]) -> None: ...@@ -399,6 +404,15 @@ def tabulate_metrics(metrics: List[PerfMetric]) -> None:
"{}".format(x.change.hint()) "{}".format(x.change.hint())
)) for x in sorted(metrics, key = )) for x in sorted(metrics, key =
lambda m: (m.stat.test, m.stat.way, m.stat.metric))] 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_table(headerRows, dataRows, 1)
print("") print("")
if hasBaseline: if hasBaseline:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment