Ring decoder: coarse-to-fine sync search (2x faster), lab phone at 960px, bench cpu throttling

This commit is contained in:
2026-08-16 18:27:34 +01:00
parent 55b5a53642
commit c6934080f1
4 changed files with 30 additions and 13 deletions
+6 -1
View File
@@ -60,6 +60,10 @@ async def main():
b = Browser(9336)
await b.start()
p = await b.page(960, 720)
throttle = float(os.environ.get("CPU", "1"))
if throttle > 1:
# rough low-end phone: chrome devtools cpu slowdown factor
await p.send("Emulation.setCPUThrottlingRate", {"rate": throttle})
await p.goto(f"http://127.0.0.1:{PORT}/static/ringlab/bench.html")
for _ in range(50):
if await p.js("!!window.benchReady"):
@@ -77,7 +81,8 @@ async def main():
a[0] += 1; a[1] += (r["found"] or 0) > 0; a[2] += r["ok"]
print(f"{key:8s}", " ".join(f"{k}: ok {v[2]}/{v[0]}" for k, v in sorted(agg.items())))
ok = sum(r["ok"] for r in codes)
print(f"codes read {ok}/{len(codes)} ({100 * ok / len(codes):.0f} %), median {sorted(r['ms'] for r in codes)[len(codes) // 2]} ms/frame")
ms = sorted(r['ms'] for r in res)
print(f"codes read {ok}/{len(codes)} ({100 * ok / len(codes):.0f} %), decode ms/frame median {ms[len(ms) // 2]} p90 {ms[int(len(ms) * .9)]}")
fails = [r for r in codes if not r["ok"]]
print("failures (d, tilt, blur, contrast, found, score, errs):",
[(r["d"], r["tilt"], r["blur"], r["contrast"], r["found"], r["score"], r.get("errs")) for r in fails[:16]])