Files
lucisv/docs/perf/take6-20261126/scripts/diffsplit.py
T
Guoliang ChenandClaude Mythos 5.2 f2d9ff01dc Take 6: OpenTitan performance report, 0.66.2 against Rounds 1-12
Measures 71d13b5 against aa2259b on 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]>
2026-11-26 21:59:18 -08:00

28 lines
1.3 KiB
Python

# Author: Guoliang Chen, a Senior Digital Design Engineer
"""Per-file hashes of a lucisv --diff stream: python3 -I diffsplit.py a.diff b.diff -> summary JSON."""
import hashlib, json, sys
def split(path):
files, cur, buf = {}, None, []
with open(path, encoding="utf-8", errors="surrogateescape") as f:
lines = f.readlines()
i = 0
while i < len(lines):
l = lines[i]
if l.startswith("--- ") and i + 1 < len(lines) and lines[i+1].startswith("+++ ") and l[4:].strip() == lines[i+1][4:].strip():
if cur: files[cur] = "".join(buf)
cur = l[4:].strip().replace("/Users/lucio/repo/opentitan/", ""); buf = []
i += 2; continue
buf.append(l); i += 1
if cur: files[cur] = "".join(buf)
return files
a, b = split(sys.argv[1]), split(sys.argv[2])
h = lambda s: hashlib.sha256(s.encode("utf-8", "surrogateescape")).hexdigest()
differ = sorted(p for p in set(a) | set(b) if h(a.get(p, "")) != h(b.get(p, "")))
only_a = sorted(set(a) - set(b)); only_b = sorted(set(b) - set(a))
print(json.dumps({"files_a": len(a), "files_b": len(b), "differ": len(differ), "only_a": only_a, "only_b": only_b,
"sha256_a": h("".join(a[k] for k in sorted(a))), "sha256_b": h("".join(b[k] for k in sorted(b))),
"differing_files": differ}))
# Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com