From a7053a6c04496fa26a62bb3824ccc9664909a6ec Mon Sep 17 00:00:00 2001
From: sheaf <sam.derbyshire@gmail.com>
Date: Fri, 29 Apr 2022 21:21:42 +0200
Subject: [PATCH] Testsuite driver: don't crash on empty metrics

The testsuite driver crashed when trying to display minimum/maximum
performance changes when there are no metrics (i.e. there is
no baseline available). This patch fixes that.
---
 testsuite/driver/runtests.py | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/testsuite/driver/runtests.py b/testsuite/driver/runtests.py
index 6a68b67714ce..a7abfdf3b94c 100644
--- a/testsuite/driver/runtests.py
+++ b/testsuite/driver/runtests.py
@@ -425,13 +425,17 @@ def tabulate_metrics(metrics: List[PerfMetric]) -> None:
         for x in metrics
         if x.baseline is not None
     ]
+    minimum = 0.0
+    maximum = 0.0
+    if len(changes) > 0:
+      minimum = 100 * (min(changes) - 1)
+      maximum = 100 * (max(changes) - 1)
     dataRows += [
         row(("", "", "", "", "", "", "", "")),
         row(("geo. mean", "", "", "", "", "", "{:+4.1f}%".format(100*(geometric_mean(changes)-1)), "")),
-        row(("minimum  ", "", "", "", "", "", "{:+4.1f}%".format(100*(min(changes)-1)), "")),
-        row(("maximum  ", "", "", "", "", "", "{:+4.1f}%".format(100*(max(changes)-1)), "")),
+        row(("minimum  ", "", "", "", "", "", "{:+4.1f}%".format(minimum), "")),
+        row(("maximum  ", "", "", "", "", "", "{:+4.1f}%".format(maximum), "")),
     ]
-
     print_table(headerRows, dataRows, 1)
     print("")
     if hasBaseline:
-- 
GitLab