Measures71d13b5againstaa2259bon OpenTitan hw (CLI, LSP, MCP), with raw logs and drivers under docs/perf/take6-20261126/. Docs only. Co-Authored-By: Claude Mythos 5.2 <[email protected]>
58 lines
2.1 KiB
Python
58 lines
2.1 KiB
Python
# Author: Guoliang Chen, a Senior Digital Design Engineer
|
|
|
|
"""Alternating before/after CLI timing over opentitan hw.
|
|
|
|
python3 -I cli_time.py <out.jsonl> <N> <cmd-name>...
|
|
One untimed warm-up per (binary, command), then N timed pairs, the order of the
|
|
pair swapped every iteration. Every run goes through tools/guard.sh -m 8 -t 600.
|
|
"""
|
|
import json
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
|
|
S = os.path.dirname(os.path.abspath(__file__))
|
|
GUARD = "/Users/lucio/repo/lucisv/tools/guard.sh"
|
|
HW = "/Users/lucio/repo/opentitan/hw"
|
|
BINS = {"0.66.2": S + "/bin-base/lucisv", "HEAD": S + "/bin-head/lucisv"}
|
|
CMDS = {
|
|
"fmt-default": ["--check", "--no-cache", HW],
|
|
"fmt-auto": ["--style", "auto", "--check", "--no-cache", HW],
|
|
"fmt-lowrisc": ["--style", "lowrisc", "--check", "--no-cache", HW],
|
|
"check": ["check", HW],
|
|
"fmt-default-t1": ["--threads", "1", "--check", "--no-cache", HW],
|
|
}
|
|
|
|
out_path, n = sys.argv[1], int(sys.argv[2])
|
|
names = sys.argv[3:] or list(CMDS)
|
|
|
|
|
|
def run(label, name, kind, i):
|
|
cmd = [GUARD, "-m", "8", "-t", "600", "--", sys.executable, "-I", S + "/timer.py",
|
|
"--", BINS[label]] + CMDS[name]
|
|
load = os.getloadavg()[0]
|
|
p = subprocess.run(cmd, capture_output=True, text=True, cwd=S)
|
|
try:
|
|
row = json.loads(p.stdout.strip().splitlines()[-1])
|
|
except (IndexError, ValueError):
|
|
row = {"error": (p.stdout + p.stderr)[-500:], "guard_exit": p.returncode}
|
|
row.update({"label": label, "cmd": name, "kind": kind, "i": i, "load1": round(load, 2),
|
|
"argv": [os.path.basename(BINS[label])] + CMDS[name],
|
|
"ts": time.strftime("%Y-%m-%dT%H:%M:%S")})
|
|
with open(out_path, "a") as f:
|
|
f.write(json.dumps(row) + "\n")
|
|
print(name, label, kind, i, row.get("wall_ms"), row.get("summary"), flush=True)
|
|
|
|
|
|
for name in names:
|
|
for label in BINS:
|
|
run(label, name, "warmup", 0)
|
|
order = list(BINS)
|
|
for i in range(1, n + 1):
|
|
for label in order:
|
|
run(label, name, "timed", i)
|
|
order.reverse()
|
|
|
|
# Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
|