From 84d3870060d9725234cd4c324df85e1ad1f87d33 Mon Sep 17 00:00:00 2001 From: bra-fsn Date: Thu, 30 May 2024 21:47:32 +0200 Subject: [PATCH] openssl parser --- inspector/parse.py | 37 +++++++++++++++++++++++++++++++++++++ inspector/tasks.py | 1 + 2 files changed, 38 insertions(+) diff --git a/inspector/parse.py b/inspector/parse.py index 3a361b6..b9739ba 100644 --- a/inspector/parse.py +++ b/inspector/parse.py @@ -133,3 +133,40 @@ def dmidecode(meta, task, task_dir) -> None: parsed_output.append(dmi_propvals(d)) with open(os.path.join(task_dir, "parsed.json"), "w") as f: json.dump(parsed_output, f, indent=2) + + +def openssl(meta, task, task_dir) -> None: + """ + Parses openssl speed -mr output from multiple, separate (one algo per run) runs, with a separator of + `ALGO: (optional -evp option) algo_name ----` + """ + data = open(os.path.join(task_dir, "stdout"), "r").read() + lines = data.splitlines() + parsed_output = [] + + for line in lines: + if m := re.search(r"^ALGO:( -[^\s]+ | )([^\s]+) --------------", line): + # algo start + # ALGO: -evp blake2b512 ---- + # ALGO: X448 ---- + algo = m.group(2) + # new test, (re)set reused variables + blocksizes = [] + + if m := re.search(r"^\+DT:[^\s:]+:[0-9]+:[0-9]+", line): + algo = m.group(0).split(":")[1] + if m := re.search(r"\+H(:[0-9]+)+", line): + # tells us the block sizes used for this test + # Single core example (no -multi): + # +H:16:64:256:1024 + # Multi core example (-multi, even with -multi 1) + # Got: +H:16:64:256:1024:8192:16384 from 15 + blocksizes = list(map(int, m.group(0).split(":")[1:])) + if m := re.search(r"^\+F:[0-9]+:" + algo + "(:[0-9.]+)+$", line): + res = m.group(0).split(":") + algo = res[2] + speed = res[3:] + for i in range(len(blocksizes)): + parsed_output.append(dict(algo=algo, block_size=blocksizes[i], speed=float(speed[i]), speed_unit="bytes/sec")) + with open(os.path.join(task_dir, "parsed.json"), "w") as f: + json.dump(parsed_output, f, indent=2) diff --git a/inspector/tasks.py b/inspector/tasks.py index e1aaddc..fea8918 100644 --- a/inspector/tasks.py +++ b/inspector/tasks.py @@ -50,6 +50,7 @@ class Openssl(lib.DockerTask): parallel: bool = False priority: int = 2 image: str = "ghcr.io/sparecores/benchmark:main" + parse_output: list = [parse.openssl] version_command: str = "bash -c \"openssl version | awk '{print $2}'\"" command: str = "openssl.sh"