in testsuite/driver/perf_notes.py [0:0]
def allow_changes_string(changes):
Dec = MetricChange.Decrease
Inc = MetricChange.Increase
# We only care about increase / decrease metrics.
changes = [change for change in changes if change[0] in [Inc, Dec]]
# Map tests to a map from change direction to metrics.
test_to_dir_to_metrics = {}
for (change, perf_stat) in changes:
change_dir_to_metrics = test_to_dir_to_metrics.setdefault(perf_stat.test, { Inc: [], Dec: [] })
change_dir_to_metrics[change].append(perf_stat.metric)
# Split into 3 groups.
# Tests where all changes are *increasing*.
# Tests where all changes are *decreasing*.
# Tests where changes are *mixed* increasing and decreasing.
groupDec = []
groupInc = []
groupMix = []
for (test, decsAndIncs) in test_to_dir_to_metrics.items():
decs = decsAndIncs[Dec]
incs = decsAndIncs[Inc]
if decs and incs:
groupMix.append(test)
elif not decs:
groupInc.append(test)
else:
groupDec.append(test)
msgs = []
nltab = '\n '
# Decreasing group.
if groupDec:
msgs.append('Metric Decrease:' + nltab + nltab.join(groupDec))
# Increasing group.
if groupInc:
msgs.append('Metric Increase:' + nltab + nltab.join(groupInc))
# Mixed group.
if groupMix:
# Split mixed group tests by decrease/increase, then by metric.
dir_to_metric_to_tests = {
Dec: {},
Inc: {}
}
for test in groupMix:
for change_dir, metrics in test_to_dir_to_metrics[test].items():
for metric in metrics:
dir_to_metric_to_tests[change_dir].setdefault(metric, []).append(test)
for change_dir in [Dec, Inc]:
metric_to_tests = dir_to_metric_to_tests[change_dir]
for metric in sorted(metric_to_tests.keys()):
tests = metric_to_tests[metric]
msgs.append('Metric ' + change_dir + ' \'' + metric + '\':' + nltab + nltab.join(tests))
return '\n\n'.join(msgs)