Loading ci/complexity_measurements/genWebpageData_WMOPS.py +104 −11 Original line number Diff line number Diff line Loading @@ -13,6 +13,10 @@ RUNS_KEYS_WMOPS = RUNS_KEYS_COMMON + [ "worstCaseCodecRs", "fixpointScalingFac", ] RUNS_KEYS_WMOPS_PER_OP = [ "operatingPoint", "mode", ] RUNS_KEYS_ROM = RUNS_KEYS_COMMON + [ "PromEnc", "PromDec", Loading @@ -36,11 +40,13 @@ RUNS_KEYS = { "wmops": RUNS_KEYS_WMOPS, "rom": RUNS_KEYS_ROM, "ram": RUNS_KEYS_RAM, "wmops_per_op": RUNS_KEYS_WMOPS_PER_OP, } RUNS_LINE_IDX = { "wmops": [2, 1, 0, 4, 6, 8, 12, 14, 16, 10, 18], "rom": [2, 1, 0, 4, 6, 8, 10, 12, 14, 16, 18, 20], "ram": [2, 1, 0, 4, 6, 9, 11, 14, 16, 18], "wmops_per_op": [0, 4], } DISPLAY_IDS = { Loading Loading @@ -79,11 +85,19 @@ DISPLAY_IDS = { "maxHeapEncScore", "maxHeapDecScore", ], "wmops_per_op": [ "worstCaseEnc", "worstCaseDec", ], } DISPLAY_LINE_IDX = { "wmops": [-1, 9, 3, 5, 7, 17, 11, 13, 15], "rom": [-1, 3, 5, 7, 9, 11, 13, 15, 17, 19], "ram": [-1, 3, 5, 7, 8, 10, 12, 13, 15, 17], "wmops_per_op": [1, 2], } DISPLAY_LABELS = { "wmops_per_op": ["Encoder", "Decoder"], } DISPLAY_ELEM_TEMPLATE = '{{ lines: {{ show: true }}, points: {{ show: true, fillColor: "#ffffff" }}, borderWidth: 1.5, borderColor: "#BEBEBE", markingsLineWidth: .75, hoverable: true, clickable: false, shadowSize: 0, color: "{color}", id: "{id}", data: [ {data} ] }}' Loading Loading @@ -123,12 +137,19 @@ LINE_COLORS = { "#0000FF", "#0080C0", ], "wmops_per_op": [ "#CF4B4B", "#008040", ], } JS_FILE_TEMPLATE = """var {var_name} = {{ {elem_name}: {{ description: "{description}", direction: -1, ticks: [ {ticks} ], runs: [ {runs} ], Loading Loading @@ -167,31 +188,92 @@ FILE_DATA = { "requirementRam": 0, }, }, "wmops_per_op": { "var_name": "Graphs_WMOPS_perOP", "elem_name": "wmops_worstcase_per_op", "description": "Worst Case WMOPS per OP", "filename": "graphs_wmops_flc_perOP.js", "references": {}, }, } def main(wmops_log, rom_log, ram_log): def main(wmops_log, wmops_per_op_log, rom_log, ram_log): FILE_DATA["wmops"]["log_file"] = wmops_log FILE_DATA["wmops_per_op"]["log_file"] = wmops_per_op_log FILE_DATA["rom"]["log_file"] = rom_log FILE_DATA["ram"]["log_file"] = ram_log for x, data in FILE_DATA.items(): with open(data["log_file"]) as f: log_lines = f.readlines()[-MAX_VALUES:] log_lines = f.readlines() split_char = " " ticks = [] if x == "wmops_per_op": split_char = ";" # some preprocessing is needed so that the later functions work as are # 1. need to make sure that modes are ordered by bandwidth # 2. need to add the bandwidth indicator as a column wb_lines, swb_lines, fb_lines = [], [], [] for line in log_lines: if " WB " in line: wb_lines.append(line + ";WB") elif " SWB " in line: swb_lines.append(line + ";SWB") elif " FB " in line: fb_lines.append(line + ";FB") log_lines = wb_lines + swb_lines + fb_lines runs = [create_runs_string(line.strip().split(" "), x) for line in log_lines] # generate tick positions and x axis labels from the number of lines in_between_offset_size = 1 wb_label_pos = len(wb_lines) / 2 swb_label_pos = len(wb_lines) + in_between_offset_size + len(swb_lines) / 2 fb_label_pos = ( len(wb_lines) + in_between_offset_size + len(swb_lines) + in_between_offset_size + len(fb_lines) / 2 ) ticks = [ f"['{wb_label_pos}', 'WB']", f"['{swb_label_pos}', 'SWB']", f"['{fb_label_pos}', 'FB']", ] else: log_lines = log_lines[-MAX_VALUES:] runs = [ create_runs_string(line.strip().split(split_char), x) for line in log_lines ] display_ids = DISPLAY_IDS[x] display_line_idx = DISPLAY_LINE_IDX[x] line_colors = LINE_COLORS[x] display_labels = DISPLAY_LABELS.get(x, [""] * len(display_ids)) # TODO: can be refactored now that x is passed displays = [ create_display_string(log_lines, id, idx, color, data["references"]) for id, idx, color in zip( DISPLAY_IDS[x], DISPLAY_LINE_IDX[x], LINE_COLORS[x] create_display_string( log_lines, id, idx, color, data["references"], split_char, label, x ) for id, idx, color, label in zip( display_ids, display_line_idx, line_colors, display_labels ) ] runs = ",\n".join(runs) displays = ",\n".join(displays) ticks = ",\n".join(ticks) js_string = JS_FILE_TEMPLATE.format( var_name=data["var_name"], elem_name=data["elem_name"], description=data["description"], runs=",\n".join(runs), displays=",\n".join(displays), runs=runs, displays=displays, ticks=ticks, ) with open(data["filename"], "w") as f: print(js_string, file=f) Loading @@ -199,30 +281,41 @@ def main(wmops_log, rom_log, ram_log): def create_runs_string(line: list[str], which: str) -> str: keys = RUNS_KEYS[which] vals = [line[i] for i in RUNS_LINE_IDX[which]] run = str(dict(zip(keys, vals))) return run def create_display_string(log_lines, id, idx, color, references): def create_display_string( log_lines, id, idx, color, references, split_char, label, which ): data = list() for i, line in enumerate(log_lines): value = line.split(" ")[idx] value = line.split(split_char)[idx] if id in references: value = references[id] data.append(f"[{i}, {value}]") display = DISPLAY_ELEM_TEMPLATE.format(color=color, id=id, data=", ".join(data)) if which == "wmops_per_op": display = display.replace("show: true", "show: false") idx_data = display.index("data:") label_string = f"label: '{label}', " display = display[:idx_data] + label_string + display[idx_data:] return display if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("wmops_log") parser.add_argument("wmops_per_op_log") parser.add_argument("rom_log") parser.add_argument("ram_log") args = parser.parse_args() main(args.wmops_log, args.rom_log, args.ram_log) main(args.wmops_log, args.wmops_per_op_log, args.rom_log, args.ram_log) Loading
ci/complexity_measurements/genWebpageData_WMOPS.py +104 −11 Original line number Diff line number Diff line Loading @@ -13,6 +13,10 @@ RUNS_KEYS_WMOPS = RUNS_KEYS_COMMON + [ "worstCaseCodecRs", "fixpointScalingFac", ] RUNS_KEYS_WMOPS_PER_OP = [ "operatingPoint", "mode", ] RUNS_KEYS_ROM = RUNS_KEYS_COMMON + [ "PromEnc", "PromDec", Loading @@ -36,11 +40,13 @@ RUNS_KEYS = { "wmops": RUNS_KEYS_WMOPS, "rom": RUNS_KEYS_ROM, "ram": RUNS_KEYS_RAM, "wmops_per_op": RUNS_KEYS_WMOPS_PER_OP, } RUNS_LINE_IDX = { "wmops": [2, 1, 0, 4, 6, 8, 12, 14, 16, 10, 18], "rom": [2, 1, 0, 4, 6, 8, 10, 12, 14, 16, 18, 20], "ram": [2, 1, 0, 4, 6, 9, 11, 14, 16, 18], "wmops_per_op": [0, 4], } DISPLAY_IDS = { Loading Loading @@ -79,11 +85,19 @@ DISPLAY_IDS = { "maxHeapEncScore", "maxHeapDecScore", ], "wmops_per_op": [ "worstCaseEnc", "worstCaseDec", ], } DISPLAY_LINE_IDX = { "wmops": [-1, 9, 3, 5, 7, 17, 11, 13, 15], "rom": [-1, 3, 5, 7, 9, 11, 13, 15, 17, 19], "ram": [-1, 3, 5, 7, 8, 10, 12, 13, 15, 17], "wmops_per_op": [1, 2], } DISPLAY_LABELS = { "wmops_per_op": ["Encoder", "Decoder"], } DISPLAY_ELEM_TEMPLATE = '{{ lines: {{ show: true }}, points: {{ show: true, fillColor: "#ffffff" }}, borderWidth: 1.5, borderColor: "#BEBEBE", markingsLineWidth: .75, hoverable: true, clickable: false, shadowSize: 0, color: "{color}", id: "{id}", data: [ {data} ] }}' Loading Loading @@ -123,12 +137,19 @@ LINE_COLORS = { "#0000FF", "#0080C0", ], "wmops_per_op": [ "#CF4B4B", "#008040", ], } JS_FILE_TEMPLATE = """var {var_name} = {{ {elem_name}: {{ description: "{description}", direction: -1, ticks: [ {ticks} ], runs: [ {runs} ], Loading Loading @@ -167,31 +188,92 @@ FILE_DATA = { "requirementRam": 0, }, }, "wmops_per_op": { "var_name": "Graphs_WMOPS_perOP", "elem_name": "wmops_worstcase_per_op", "description": "Worst Case WMOPS per OP", "filename": "graphs_wmops_flc_perOP.js", "references": {}, }, } def main(wmops_log, rom_log, ram_log): def main(wmops_log, wmops_per_op_log, rom_log, ram_log): FILE_DATA["wmops"]["log_file"] = wmops_log FILE_DATA["wmops_per_op"]["log_file"] = wmops_per_op_log FILE_DATA["rom"]["log_file"] = rom_log FILE_DATA["ram"]["log_file"] = ram_log for x, data in FILE_DATA.items(): with open(data["log_file"]) as f: log_lines = f.readlines()[-MAX_VALUES:] log_lines = f.readlines() split_char = " " ticks = [] if x == "wmops_per_op": split_char = ";" # some preprocessing is needed so that the later functions work as are # 1. need to make sure that modes are ordered by bandwidth # 2. need to add the bandwidth indicator as a column wb_lines, swb_lines, fb_lines = [], [], [] for line in log_lines: if " WB " in line: wb_lines.append(line + ";WB") elif " SWB " in line: swb_lines.append(line + ";SWB") elif " FB " in line: fb_lines.append(line + ";FB") log_lines = wb_lines + swb_lines + fb_lines runs = [create_runs_string(line.strip().split(" "), x) for line in log_lines] # generate tick positions and x axis labels from the number of lines in_between_offset_size = 1 wb_label_pos = len(wb_lines) / 2 swb_label_pos = len(wb_lines) + in_between_offset_size + len(swb_lines) / 2 fb_label_pos = ( len(wb_lines) + in_between_offset_size + len(swb_lines) + in_between_offset_size + len(fb_lines) / 2 ) ticks = [ f"['{wb_label_pos}', 'WB']", f"['{swb_label_pos}', 'SWB']", f"['{fb_label_pos}', 'FB']", ] else: log_lines = log_lines[-MAX_VALUES:] runs = [ create_runs_string(line.strip().split(split_char), x) for line in log_lines ] display_ids = DISPLAY_IDS[x] display_line_idx = DISPLAY_LINE_IDX[x] line_colors = LINE_COLORS[x] display_labels = DISPLAY_LABELS.get(x, [""] * len(display_ids)) # TODO: can be refactored now that x is passed displays = [ create_display_string(log_lines, id, idx, color, data["references"]) for id, idx, color in zip( DISPLAY_IDS[x], DISPLAY_LINE_IDX[x], LINE_COLORS[x] create_display_string( log_lines, id, idx, color, data["references"], split_char, label, x ) for id, idx, color, label in zip( display_ids, display_line_idx, line_colors, display_labels ) ] runs = ",\n".join(runs) displays = ",\n".join(displays) ticks = ",\n".join(ticks) js_string = JS_FILE_TEMPLATE.format( var_name=data["var_name"], elem_name=data["elem_name"], description=data["description"], runs=",\n".join(runs), displays=",\n".join(displays), runs=runs, displays=displays, ticks=ticks, ) with open(data["filename"], "w") as f: print(js_string, file=f) Loading @@ -199,30 +281,41 @@ def main(wmops_log, rom_log, ram_log): def create_runs_string(line: list[str], which: str) -> str: keys = RUNS_KEYS[which] vals = [line[i] for i in RUNS_LINE_IDX[which]] run = str(dict(zip(keys, vals))) return run def create_display_string(log_lines, id, idx, color, references): def create_display_string( log_lines, id, idx, color, references, split_char, label, which ): data = list() for i, line in enumerate(log_lines): value = line.split(" ")[idx] value = line.split(split_char)[idx] if id in references: value = references[id] data.append(f"[{i}, {value}]") display = DISPLAY_ELEM_TEMPLATE.format(color=color, id=id, data=", ".join(data)) if which == "wmops_per_op": display = display.replace("show: true", "show: false") idx_data = display.index("data:") label_string = f"label: '{label}', " display = display[:idx_data] + label_string + display[idx_data:] return display if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("wmops_log") parser.add_argument("wmops_per_op_log") parser.add_argument("rom_log") parser.add_argument("ram_log") args = parser.parse_args() main(args.wmops_log, args.rom_log, args.ram_log) main(args.wmops_log, args.wmops_per_op_log, args.rom_log, args.ram_log)