[debuginfo-tests] 527bd24 - [debuginfo-tests][dexter] Add a test tool --calculate-average option
via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 28 02:01:40 PST 2020
Author: Pierre-vh
Date: 2020-02-28T10:00:37Z
New Revision: 527bd24c3b41a54cef241ea2a1be53f4a4dedb17
URL: https://github.com/llvm/llvm-project/commit/527bd24c3b41a54cef241ea2a1be53f4a4dedb17
DIFF: https://github.com/llvm/llvm-project/commit/527bd24c3b41a54cef241ea2a1be53f4a4dedb17.diff
LOG: [debuginfo-tests][dexter] Add a test tool --calculate-average option
Differential Revision: https://reviews.llvm.org/D75235
Added:
Modified:
debuginfo-tests/dexter/dex/tools/test/Tool.py
Removed:
################################################################################
diff --git a/debuginfo-tests/dexter/dex/tools/test/Tool.py b/debuginfo-tests/dexter/dex/tools/test/Tool.py
index 9df1d082ace8..91c9dd48bb63 100644
--- a/debuginfo-tests/dexter/dex/tools/test/Tool.py
+++ b/debuginfo-tests/dexter/dex/tools/test/Tool.py
@@ -6,6 +6,7 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""Test tool."""
+import math
import os
import csv
import pickle
@@ -94,6 +95,9 @@ def add_tool_arguments(self, parser, defaults):
help='exit with status FAIL(2) if the test result'
' is less than this value.',
metavar='<float>')
+ parser.add_argument('--calculate-average',
+ action="store_true",
+ help='calculate the average score of every test run')
super(Tool, self).add_tool_arguments(parser, defaults)
def _build_test_case(self):
@@ -226,6 +230,19 @@ def _handle_results(self) -> ReturnCode:
if not options.verbose:
self.context.o.auto('\n')
+ if options.calculate_average:
+ # Calculate and print the average score
+ score_sum = 0.0
+ num_tests = 0
+ for test_case in self._test_cases:
+ score = test_case.score
+ if not test_case.error and not math.isnan(score):
+ score_sum += test_case.score
+ num_tests += 1
+
+ if num_tests != 0:
+ print("@avg: ({:.4f})".format(score_sum/num_tests))
+
summary_path = os.path.join(options.results_directory, 'summary.csv')
with open(summary_path, mode='w', newline='') as fp:
writer = csv.writer(fp, delimiter=',')
More information about the llvm-commits
mailing list