Loading ci/complexity_measurements/check_for_changes.py 0 → 100644 +76 −0 Original line number Diff line number Diff line import argparse import csv import sys import numpy as np THRESH = 0.01 COLS = [ [3, 5, 7, 9], # wmops_all [3,5,7,8,10,12,13,15,17], # ram_all [3,5,7,9,11,13,15,17,19], # rom_all ] def main(args): linewise_logfiles = [args.wmops_logfile, args.ram_logfile, args.rom_logfile] changes_found_linewise = any([check_linewise_logfile(f, c) for f, c in zip(linewise_logfiles, COLS)]) per_op_logfiles = [(args.per_op_wmops_logfile_curr, args.per_op_wmops_logfile_prev), (args.per_op_ram_logfile_curr, args.per_op_ram_logfile_prev), (args.per_op_rom_logfile_curr, args.per_op_rom_logfile_prev)] changes_found_per_op = any([compare_per_operating_point_logfiles(c, p) for c, p in per_op_logfiles]) if changes_found_linewise: print("Global max of WMOPS, RAM or ROM changed") if changes_found_per_op: print("Some other operating point changed") return int(changes_found_linewise or changes_found_per_op) def check_linewise_logfile(filepath, cols): with open(filepath) as f: contents = [line for line in csv.reader(f, delimiter=" ")] curr = contents[-1] prev = contents[-2] change_ratios = [abs(float(curr[i]) / float(prev[i]) - 1) > THRESH for i in cols] changes_found = any(change_ratios) return changes_found def compare_per_operating_point_logfiles(file_curr, file_prev): dtypes = [("mode", None), ("enc", float), ("dec", float), ("total", float)] curr = np.genfromtxt(file_curr, delim=";", dtype=None, skip_header=1) prev = np.genfromtxt(file_prev, delim=";", dtype=None, skip_header=1) columns = [d[0] for d in dtypes] curr_sorted = np.sort(curr, axis=0, order=columns) prev_sorted = np.sort(prev, axis=0, order=columns) changes_found = False for col in columns: diff = np.abs(curr_sorted[col] / prev_sorted[col] - 1) if np.any(diff > THRESH): changes_found = True return changes_found if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("wmops_logfile") parser.add_argument("ram_logfile") parser.add_argument("rom_logfile") parser.add_argument("per_op_wmops_logfile_curr") parser.add_argument("per_op_wmops_logfile_prev") parser.add_argument("per_op_ram_logfile_curr") parser.add_argument("per_op_ram_logfile_prev") parser.add_argument("per_op_rom_logfile_curr") parser.add_argument("per_op_rom_logfile_prev") args = parser.parse_args() sys.exit(main(args)) Loading
ci/complexity_measurements/check_for_changes.py 0 → 100644 +76 −0 Original line number Diff line number Diff line import argparse import csv import sys import numpy as np THRESH = 0.01 COLS = [ [3, 5, 7, 9], # wmops_all [3,5,7,8,10,12,13,15,17], # ram_all [3,5,7,9,11,13,15,17,19], # rom_all ] def main(args): linewise_logfiles = [args.wmops_logfile, args.ram_logfile, args.rom_logfile] changes_found_linewise = any([check_linewise_logfile(f, c) for f, c in zip(linewise_logfiles, COLS)]) per_op_logfiles = [(args.per_op_wmops_logfile_curr, args.per_op_wmops_logfile_prev), (args.per_op_ram_logfile_curr, args.per_op_ram_logfile_prev), (args.per_op_rom_logfile_curr, args.per_op_rom_logfile_prev)] changes_found_per_op = any([compare_per_operating_point_logfiles(c, p) for c, p in per_op_logfiles]) if changes_found_linewise: print("Global max of WMOPS, RAM or ROM changed") if changes_found_per_op: print("Some other operating point changed") return int(changes_found_linewise or changes_found_per_op) def check_linewise_logfile(filepath, cols): with open(filepath) as f: contents = [line for line in csv.reader(f, delimiter=" ")] curr = contents[-1] prev = contents[-2] change_ratios = [abs(float(curr[i]) / float(prev[i]) - 1) > THRESH for i in cols] changes_found = any(change_ratios) return changes_found def compare_per_operating_point_logfiles(file_curr, file_prev): dtypes = [("mode", None), ("enc", float), ("dec", float), ("total", float)] curr = np.genfromtxt(file_curr, delim=";", dtype=None, skip_header=1) prev = np.genfromtxt(file_prev, delim=";", dtype=None, skip_header=1) columns = [d[0] for d in dtypes] curr_sorted = np.sort(curr, axis=0, order=columns) prev_sorted = np.sort(prev, axis=0, order=columns) changes_found = False for col in columns: diff = np.abs(curr_sorted[col] / prev_sorted[col] - 1) if np.any(diff > THRESH): changes_found = True return changes_found if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("wmops_logfile") parser.add_argument("ram_logfile") parser.add_argument("rom_logfile") parser.add_argument("per_op_wmops_logfile_curr") parser.add_argument("per_op_wmops_logfile_prev") parser.add_argument("per_op_ram_logfile_curr") parser.add_argument("per_op_ram_logfile_prev") parser.add_argument("per_op_rom_logfile_curr") parser.add_argument("per_op_rom_logfile_prev") args = parser.parse_args() sys.exit(main(args))