Adds 6 benchmark scripts in tests/benchmarks/ covering all 5 scenarios from
Kanboard #37, plus a shared baseline helper:
grid_step_bench.py 100 ent / 100x100 grid / 1000 grid.step() rounds
mix of IDLE/NOISE8/SEEK/FLEE behaviors
fov_opt_bench.py 100 ent / 1000x1000 grid; entity.update_visibility()
(with DiscreteMap perspective writeback) vs bare
grid.compute_fov() (no writeback) across FOV
algorithms BASIC/SHADOW/SYMMETRIC_SHADOWCAST and
radii 8/16/32
spatial_hash_bench.py entities_in_radius() at radii (1,5,10,50) x
entity counts (100,1k,10k); compares against
naive O(n) baseline with hit-count validation
pathfinding_bench.py A* across grid sizes/densities/heuristics/weights,
plus with-vs-without `collide=` collision-label
comparison (0/10/100 blockers on 100x100)
gridview_render_bench.py 1/2/4 GridViews on shared grid; uses
automation.screenshot() to force real renders in
headless mode (mcrfpy.step alone is render-stubbed)
dijkstra_bench.py single-root, multi-root, mask, invert, descent
_baseline.py writes baseline JSON to baseline/phase5_2/
All scripts emit JSON to stdout and write a baseline copy under
tests/benchmarks/baseline/phase5_2/ for regression comparison. All run
headless; pure time.perf_counter() timing for compute benches, screenshot
wall-time for the render bench (start/end_benchmark would only capture the
no-op headless game loop, so direct timing is used).
Notable findings captured in baselines:
- spatial hash: 5x to >300x speedup over naive O(n), hits validated identical
- update_visibility: ~25-37 ms/entity perspective writeback overhead on
1000x1000 grid (full-grid demote+promote loop in UIEntity::updateVisibility)
dominates over the actual TCOD FOV cost (~3-24 ms). Worth a follow-up issue
for sparse perspective updating.
- gridview render: per-view cost scales near-linearly down (~78ms total for
1, 2, or 4 views) -- the multi-view system shares state efficiently.
Refs Kanboard #37.