Commit e61cbc45 authored by Jan Kiene's avatar Jan Kiene
Browse files

add rom JS file generation

parent e50dfbf8
Loading
Loading
Loading
Loading
+76 −20
Original line number Diff line number Diff line
@@ -14,12 +14,25 @@ RUNS_KEYS_WMOPS = RUNS_KEYS_COMMON + [
    "fixpointScalingFac",
    "logFile",
]
RUNS_KEYS_ROM = RUNS_KEYS_COMMON + [
    "PromEnc",
    "PromDec",
    "PromCom",
    "PromRend",
    "TromEnc",
    "TromDec",
    "TromCom",
    "TromRend",
    "logFile",
]

RUNS_KEYS = {
    "wmops": RUNS_KEYS_WMOPS,
    "rom": RUNS_KEYS_ROM,
}
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],
}

DISPLAY_IDS = {
@@ -33,14 +46,28 @@ DISPLAY_IDS = {
        "worst case enc/dec rs",
        "worst case enc rs",
        "worst case dec rs",
    ]
    ],
    "rom": [
        "requirementRom",
        "TotalRomCodecScore",
        "maxPROMEncScore",
        "maxPROMDecScore",
        "maxPROMComScore",
        "maxPROMRendScore",
        "maxTROMEncScore",
        "maxTROMDecScore",
        "maxTROMComScore",
        "maxTROMRendScore",
    ],
}
DISPLAY_LINE_IDX = {
    "wmops": [-1, 9, 3, 5, 7, 17, 11, 13, 15],
    "rom": [-1, 3, 5, 7, 9, 11, 13, 15, 17, 19],
}
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} ] }}'

LINE_COLORS = [
LINE_COLORS = {
    "wmops": [
        "#000000",
        "#0080FF",
        "#FF8000",
@@ -50,7 +77,20 @@ LINE_COLORS = [
        "#FFC480",
        "#CF8080",
        "#00F040",
]
    ],
    "rom": [
        "#000000",
        "#FF0000",
        "#FF8000",
        "#FFFF00",
        "#800080",
        "#0000FF",
        "#0080C0",
        "#004000",
        "#008000",
        "#00FF00",
    ],
}

JS_FILE_TEMPLATE = """var {var_name} = {{
    {elem_name}: {{
@@ -72,12 +112,25 @@ FILE_DATA = {
        "elem_name": "wmops_worstcase",
        "description": "Worst Case WMOPS",
        "filename": "graphs_wmops_flc.js",
    }
        "references": {
            "requirement": 0,
        },
    },
    "rom": {
        "var_name": "Graphs_ROM",
        "elem_name": "rom_worstcase",
        "description": "ROM",
        "filename": "graphs_rom_flc.js",
        "references": {
            "requirementRom": 0,
        },
    },
}


def main(wmops_log):
def main(wmops_log, rom_log):
    FILE_DATA["wmops"]["log_file"] = wmops_log
    FILE_DATA["rom"]["log_file"] = rom_log

    for x, data in FILE_DATA.items():
        with open(data["log_file"]) as f:
@@ -85,8 +138,10 @@ def main(wmops_log):

        runs = [create_runs_string(line.strip().split(" "), x) for line in log_lines]
        displays = [
            create_display_string(log_lines, id, idx, color)
            for id, idx, color in zip(DISPLAY_IDS[x], DISPLAY_LINE_IDX[x], LINE_COLORS)
            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]
            )
        ]
        wmops_js_string = JS_FILE_TEMPLATE.format(
            var_name=data["var_name"],
@@ -107,12 +162,12 @@ def create_runs_string(line: list[str], which: str) -> str:
    return run


def create_display_string(log_lines, id, idx, color):
def create_display_string(log_lines, id, idx, color, references):
    data = list()
    for i, line in enumerate(log_lines):
        value = line.split(" ")[idx]
        if id == "requirement":
            value = 0
        if id in references:
            value = references[id]
        data.append(f"[{i}, {value}]")

    display = DISPLAY_ELEM_TEMPLATE.format(color=color, id=id, data=", ".join(data))
@@ -122,7 +177,8 @@ def create_display_string(log_lines, id, idx, color):
if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("wmops_log")
    parser.add_argument("rom_log")

    args = parser.parse_args()

    main(args.wmops_log)
    main(args.wmops_log, args.rom_log)