mirror of
https://github.com/storytold/wordcraft.git
synced 2026-10-26 03:17:28 -06:00
The five tests that assert linear layout/export/hyphenation by comparing the cost of an n-sized and a larger input (layout: unequal formats, hidden separators with auto hyphenation, hidden float anchors; pdf: fragmented hidden headings; proof: hyphenating a long word) timed both with wall clock, fastest of three. On a loaded machine (CI, shared dev boxes, the test harness running other tests in parallel) a preempted big run, timer resolution on the small run, or a tight 4x/8.0 limit (hyphenation measured ~7.2 when linear) made them fail now and then. Each now uses a shared cost_ratio helper (test-only, no production change): - CPU time of the test thread from /proc/thread-self/schedstat on Linux, so time spent waiting for a CPU is left out (wall clock elsewhere); - the small input runs `scale` times per timing so both timings are long against the clock's resolution; - small and big runs alternate, five rounds after a warm-up, cheapest kept; - 8x the input everywhere: linear ~8x, quadratic ~64x, limit 24x. Measured under load (load avg ~15-35 on 32 cores): 60 linear ratios in 7.7-8.8. With the old quadratic code injected locally each test fails: unequal formats (uncapped style bucket scan) ~90-104x, hidden separators (hyphenator rescan per point) ~36x, float anchors (run walk restarted per anchor) ~188x, PDF headings (left-out range scan per char) ~37x, hyphenation 50-65x. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>