Ring locator: contrast ranking, all-round ink check; bench baseline switch

This commit is contained in:
2026-08-16 20:12:33 +01:00
parent e677e270fd
commit b314f01efc
6 changed files with 30 additions and 10 deletions
+6 -4
View File
@@ -1,6 +1,7 @@
"""ring code bench: renders codes with perspective, blur, washed contrast and clutter in headless chrome,
runs the real decoder and prints read rates. usage: uv run python tools/ringbench.py [trials per cell]
env: SUITE=legacy,far,seq,neg (default all) PIPES=legacy,scan DIAG=legacy|native NEG=300 CPU=6 (slow phone)"""
env: SUITE=legacy,far,seq,neg (default all) PIPES=legacy,cap960,scan DIAG=legacy|native FAR_D=80,100 NEG=300
CPU=6 (slow phone) V1=1 (decoder and dash design from before the far-reading work, the baseline)"""
import asyncio
import base64
import collections
@@ -22,6 +23,7 @@ from cdp import Browser # noqa: E402
from rotatyvote import ringcode # noqa: E402
PORT = 8200
V1 = bool(os.environ.get("V1"))
rng = random.Random(11)
@@ -120,13 +122,13 @@ async def chunks(p, fn, key, items, cfg, size):
# cdp calls time out after 60 s
out = []
for i in range(0, len(items), size):
out += await p.js(f"{fn}({json.dumps({**cfg, key: items[i:i + size], 'seed': 1000 + i})})")
out += await p.js(f"{fn}({json.dumps({**cfg, key: items[i:i + size], 'seed': 1000 + i, 'v1': V1})})")
return out
async def run_legacy(p, n):
ts = trials(n)
res = await p.js(f"runBench({json.dumps({'trials': ts, 'keep': 4, 'v1': bool(os.environ.get('V1'))})})")
res = await p.js(f"runBench({json.dumps({'trials': ts, 'keep': 4, 'v1': V1})})")
harsh = [r for r in res if r.get("harsh")]
print(f"harsh perspective (close-up, 25 deg): {sum(r['ok'] for r in harsh)}/{len(harsh)}")
codes = [r for r in res if not r.get("nocode") and not r.get("harsh")]
@@ -212,7 +214,7 @@ async def run_seq(p, n, pipes):
async def main():
n = int(sys.argv[1]) if len(sys.argv) > 1 else 3
suites = os.environ.get("SUITE", "legacy,far,seq,neg").split(",")
pipes = os.environ.get("PIPES", "legacy,scan").split(",")
pipes = os.environ.get("PIPES", "legacy" if V1 else "scan").split(",")
env = {**os.environ, "PORT": str(PORT), "HOST": "127.0.0.1", "DB_PATH": "/tmp/rv-bench.db"}
server = subprocess.Popen([sys.executable, "-m", "rotatyvote"], cwd=ROOT, env=env,
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)