#!bin/python3 import sys import os if len(sys.argv) < 2: print("Please pass the name of the benchmark target as an argument!") exit(1) target = sys.argv[1] print('Comparing current modifications for benchmark target ' + target) print('Executing current version...') print(os.popen('cd cmake-build-release; make ' + target).read()) current = os.popen('chrt -rr 99 ./cmake-build-release/bin/' + target).read() print('Executing old version...') print(os.popen('git stash push').read()) print(os.popen('cd cmake-build-release; make ' + target).read()) before = os.popen('chrt -rr 99 ./cmake-build-release/bin/' + target).read() print(os.popen('git stash pop').read()) print('=======================================================') current = [float(value) for value in current.split(',')] before = [float(value) for value in before.split(',')] def formate_change(change): if change > 1.05: color = '31' elif change < 0.95: color = '32' else: color = '30' return '\033[1;' + color + ';40m %8.2f' % (change * 100) + ' %' format_string = ' '.join(['%10.2f us'] * len(current)) print('old: ' + format_string % tuple(before)) print('new: ' + format_string % tuple(current)) print('=' * 55) change = [c / b for b, c in zip(before, current)] formated_change = ''.join(list(map(formate_change, change))) print(formated_change)