Commit 9e8e7870 authored by Jan Kiene's avatar Jan Kiene
Browse files

add ram js file generation

parent e61cbc45
Loading
Loading
Loading
Loading
+51 −7
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ import argparse

MAX_VALUES = 40

RUNS_KEYS_COMMON = ["fullDate", "shortDate", "revision"]
RUNS_KEYS_COMMON = ["fullDate", "shortDate", "revision", "logFile"]
RUNS_KEYS_WMOPS = RUNS_KEYS_COMMON + [
    "worstCaseEnc",
    "worstCaseDec",
@@ -12,7 +12,6 @@ RUNS_KEYS_WMOPS = RUNS_KEYS_COMMON + [
    "worstCaseDecRs",
    "worstCaseCodecRs",
    "fixpointScalingFac",
    "logFile",
]
RUNS_KEYS_ROM = RUNS_KEYS_COMMON + [
    "PromEnc",
@@ -23,16 +22,25 @@ RUNS_KEYS_ROM = RUNS_KEYS_COMMON + [
    "TromDec",
    "TromCom",
    "TromRend",
    "logFile",
]
RUNS_KEYS_RAM = RUNS_KEYS_COMMON + [
    "maxTotalRamEnc",
    "maxTotalRamDec",
    "maxStackEnc",
    "maxStackDec",
    "maxHeapEnc",
    "maxHeapDec",
]

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

DISPLAY_IDS = {
@@ -59,10 +67,23 @@ DISPLAY_IDS = {
        "maxTROMComScore",
        "maxTROMRendScore",
    ],
    "ram": [
        "requirementRam",
        "maxTotalRamCodecScore",
        "maxTotalRamEncScore",
        "maxTotalRamDecScore",
        "maxStackCodecScore",
        "maxStackEncScore",
        "maxStackDecScore",
        "maxHeapCodecScore",
        "maxHeapEncScore",
        "maxHeapDecScore",
    ],
}
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],
}
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} ] }}'

@@ -90,6 +111,18 @@ LINE_COLORS = {
        "#008000",
        "#00FF00",
    ],
    "ram": [
        "#000000",
        "#FF0000",
        "#FF8000",
        "#FFFF00",
        "#004000",
        "#008000",
        "#00FF00",
        "#800080",
        "#0000FF",
        "#0080C0",
    ],
}

JS_FILE_TEMPLATE = """var {var_name} = {{
@@ -125,12 +158,22 @@ FILE_DATA = {
            "requirementRom": 0,
        },
    },
    "ram": {
        "var_name": "Graphs_RAM",
        "elem_name": "ram_worstcase",
        "description": "Worst Case RAM",
        "filename": "graphs_ram_flc.js",
        "references": {
            "requirementRam": 0,
        },
    },
}


def main(wmops_log, rom_log):
def main(wmops_log, rom_log, ram_log):
    FILE_DATA["wmops"]["log_file"] = wmops_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:
@@ -143,7 +186,7 @@ def main(wmops_log, rom_log):
                DISPLAY_IDS[x], DISPLAY_LINE_IDX[x], LINE_COLORS[x]
            )
        ]
        wmops_js_string = JS_FILE_TEMPLATE.format(
        js_string = JS_FILE_TEMPLATE.format(
            var_name=data["var_name"],
            elem_name=data["elem_name"],
            description=data["description"],
@@ -151,7 +194,7 @@ def main(wmops_log, rom_log):
            displays=",\n".join(displays),
        )
        with open(data["filename"], "w") as f:
            print(wmops_js_string, file=f)
            print(js_string, file=f)


def create_runs_string(line: list[str], which: str) -> str:
@@ -178,7 +221,8 @@ if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("wmops_log")
    parser.add_argument("rom_log")
    parser.add_argument("ram_log")

    args = parser.parse_args()

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