in testsuite/driver/perf_notes.py [0:0]
def commit_string(test, flag):
def delta(v1, v2):
return round((100 * (v1 - v2)/v2),2)
# Get the average value per commit (or None if that commit contains no metrics).
# Note: if the test environment is not set, this will combine metrics from all test environments.
averageValuesOrNones = []
for commit in args.commits:
values = [float(t.stat.value) for t in metrics if t.commit == commit and t.stat.test == test]
if values == []:
averageValuesOrNones.append(None)
else:
averageValuesOrNones.append(sum(values) / len(values))
if flag == 'metrics':
strings = [str(v) if v != None else '-' for v in averageValuesOrNones]
if flag == 'percentages':
# If the baseline commit has no stats, then we can not produce any percentages.
baseline = averageValuesOrNones[0]
if baseline == None:
strings = ['-' for v in averageValuesOrNones]
else:
baseline = float(baseline)
strings = ['-' if val == None else str(delta(baseline,float(val))) + '%' for val in averageValuesOrNones]
return row_fmt.format(*strings).strip()