From 6a24e8c90ac467678dbf9aeb0d16c3d36c2dcf44 Mon Sep 17 00:00:00 2001 From: Clément Pit--Claudel Date: Tue, 18 Aug 2015 18:14:36 -0700 Subject: runTests: Report mean completion time of passed tests, excluding outliers --- Test/runTests.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'Test/runTests.py') diff --git a/Test/runTests.py b/Test/runTests.py index 0232f81b..9f4fa5a5 100644 --- a/Test/runTests.py +++ b/Test/runTests.py @@ -6,6 +6,7 @@ import shutil import argparse import operator import platform +from math import floor, ceil from enum import Enum from time import time, strftime from collections import defaultdict @@ -168,6 +169,25 @@ class Test: results.append(Test.deserialize(row)) return results + @staticmethod + def mean_duration(results, margin): + durations = sorted(result.duration for result in results + if result.status == TestStatus.PASSED) + if len(durations) >= 15: + lq = durations[floor(0.25 * len(durations))] + hq = durations[ceil(0.85 * len(durations))] + iqr = hq - lq + filtered = [d for d in durations if (lq - margin * iqr) <= d <= (hq + margin * iqr)] + if filtered: + avg = sum(durations) / len(durations) + trimmed_avg = sum(filtered) / len(filtered) + outliers_count = len(durations) - len(filtered) + msg = "mean completion time: {:.2f}s".format(avg) + if outliers_count > 0: + msg += "; ignoring {} outliers: {:.2f}s".format(outliers_count, trimmed_avg) + return " ({})".format(msg) + return "" + @staticmethod def summarize(results): debug(Debug.INFO, "\nTesting complete ({} test(s))".format(len(results))) @@ -193,7 +213,8 @@ class Test: writer.write("{}\n".format(t.name)) debug(Debug.REPORT, "Some tests failed: use [runTests.py failing.lst] to rerun the failing tests") - debug(Debug.REPORT, "Testing took {:.2f}s on {} thread(s)".format(results[0].suite_time, results[0].njobs)) + debug(Debug.REPORT, "Testing took {:.2f}s on {} thread(s){}".format( + results[0].suite_time, results[0].njobs, Test.mean_duration(results, 1.5))) def run(self): -- cgit v1.2.3