Commit 98a66be7 authored by Jan Kiene's avatar Jan Kiene
Browse files

port wmops webpage creation script to python

parent 78d0014c
Loading
Loading
Loading
Loading
+50 −0
Original line number Diff line number Diff line
import argparse


RUNS_KEYS_COMMON = ["fullDate", "shortDate", "revision"]
RUNS_KEYS_WMOPS = RUNS_KEYS_COMMON + [
    "worstCaseEnc",
    "worstCaseDec",
    "worstCaseCodec",
    "worstCaseEncRs",
    "worstCaseDecRs",
    "worstCaseCodecRs",
    "fixpointScalingFac",
    "logFile",
]

RUNS_KEYS = {
    "wmops": RUNS_KEYS_WMOPS,
}
RUNS_LINE_IDX = {
    "wmops": [2, 1, 0, 4, 6, 8, 12, 14, 16, 10, 18],
}


def main(wmops_log):
    with open(wmops_log) as f:
        wmops_log_lines = f.readlines()

    wmops_runs = [
        create_runs_string(line.strip().split(" "), "wmops") for line in wmops_log_lines
    ]
    wmops_runs_string = ",\n".join(wmops_runs)

    print(wmops_runs_string)


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


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("wmops_log")

    args = parser.parse_args()

    main(args.wmops_log)