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]>
29 lines
1.2 KiB
Python
29 lines
1.2 KiB
Python
# Author: Guoliang Chen, a Senior Digital Design Engineer
|
|
|
|
"""Run one command, print one JSON line: wall ms, child peak RSS, exit, summary line.
|
|
|
|
Usage: python3 -I timer.py -- <command...>
|
|
Runs *inside* tools/guard.sh, so the guard's 1 s poll does not enter the wall time.
|
|
"""
|
|
import json
|
|
import resource
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
|
|
cmd = sys.argv[sys.argv.index("--") + 1:]
|
|
t0 = time.perf_counter()
|
|
p = subprocess.run(cmd, capture_output=True, text=True)
|
|
wall = (time.perf_counter() - t0) * 1000.0
|
|
ru = resource.getrusage(resource.RUSAGE_CHILDREN)
|
|
out = (p.stdout + p.stderr).strip().splitlines()
|
|
summary = [l for l in out if l.startswith(("found ", "Found ")) or "files would be" in l
|
|
or "file would be" in l or "left unchanged" in l or "failed to format" in l
|
|
or "could not be checked" in l]
|
|
print(json.dumps({"wall_ms": round(wall, 2), "peak_rss_kib": ru.ru_maxrss // 1024,
|
|
"user_s": round(ru.ru_utime, 3), "sys_s": round(ru.ru_stime, 3),
|
|
"exit": p.returncode, "lines": len(out),
|
|
"summary": summary[-2:] if summary else out[-1:]}))
|
|
|
|
# Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com
|