diff --git a/tools/donate-cpu-server.py b/tools/donate-cpu-server.py index 930bb2906..a50ad3034 100755 --- a/tools/donate-cpu-server.py +++ b/tools/donate-cpu-server.py @@ -3,6 +3,7 @@ # Server for 'donate-cpu.py' # Runs only under Python 3. +import collections import glob import json import os @@ -22,7 +23,7 @@ import operator # Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/ # Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic # changes) -SERVER_VERSION = "1.3.10" +SERVER_VERSION = "1.3.11" OLD_VERSION = '2.3' @@ -612,16 +613,18 @@ def headMessageIdTodayReport(resultPath: str, messageId: str) -> str: return text -# TODO: sort the results by factor def timeReport(resultPath: str, show_gt: bool) -> str: - html = '
\n' column_width = [40, 10, 10, 10, 10] html += '' html += fmt('Package', OLD_VERSION, 'Head', 'Factor', link=False, column_width=column_width) html += '\n' + data = {} + total_time_base = 0.0 total_time_head = 0.0 for filename in glob.glob(resultPath + '/*'): @@ -655,10 +658,19 @@ def timeReport(resultPath: str, show_gt: bool) -> str: time_factor = time_head / time_base else: time_factor = 0.0 - html += fmt(filename[len(resultPath)+1:], split_line[2], split_line[1], - '{:.2f}'.format(time_factor), column_width=column_width) + '\n' + pkg_name = filename[len(resultPath)+1:] + data[pkg_name] = (split_line[2], split_line[1], time_factor) break + sorted_data = sorted(data.items(), key=lambda kv: kv[1][2]) + if show_gt: + sorted_data.reverse() + + sorted_dict = collections.OrderedDict(sorted_data) + for key in sorted_dict: + html += fmt(key, sorted_dict[key][0], sorted_dict[key][1], '{:.2f}'.format(sorted_dict[key][2]), + column_width=column_width) + '\n' + html += '\n' html += '(listed above are all suspicious timings with a factor ' if show_gt: