McRogueFace/tests/benchmarks
John McCardle 59e722166a Phase 5.2: performance benchmark suite for grid/entity/FOV/pathfinding
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.
2026-04-18 06:45:40 -04:00
..
baseline Phase 5.2: performance benchmark suite for grid/entity/FOV/pathfinding 2026-04-18 06:45:40 -04:00
_baseline.py Phase 5.2: performance benchmark suite for grid/entity/FOV/pathfinding 2026-04-18 06:45:40 -04:00
benchmark_moving_entities.py Remove legacy string enum comparisons from InputState/Key/MouseButton, closes #306 2026-04-09 22:19:02 -04:00
benchmark_suite.py Remove camelCase module functions (setScale, findAll, getMetrics, setDevConsole), closes #304 2026-04-10 01:07:22 -04:00
dijkstra_bench.py Phase 5.2: performance benchmark suite for grid/entity/FOV/pathfinding 2026-04-18 06:45:40 -04:00
entity_scale_benchmark.py Timer overhaul: update tests 2026-01-03 22:44:53 -05:00
fov_opt_bench.py Phase 5.2: performance benchmark suite for grid/entity/FOV/pathfinding 2026-04-18 06:45:40 -04:00
grid_step_bench.py Phase 5.2: performance benchmark suite for grid/entity/FOV/pathfinding 2026-04-18 06:45:40 -04:00
gridview_render_bench.py Phase 5.2: performance benchmark suite for grid/entity/FOV/pathfinding 2026-04-18 06:45:40 -04:00
layer_performance_test.py Timer overhaul: update tests 2026-01-03 22:44:53 -05:00
pathfinding_bench.py Phase 5.2: performance benchmark suite for grid/entity/FOV/pathfinding 2026-04-18 06:45:40 -04:00
spatial_hash_bench.py Phase 5.2: performance benchmark suite for grid/entity/FOV/pathfinding 2026-04-18 06:45:40 -04:00
stress_test_suite.py Timer overhaul: update tests 2026-01-03 22:44:53 -05:00
tcod_fov_isolated.py Timer overhaul: update tests 2026-01-03 22:44:53 -05:00
tcod_scale_test.py Timer overhaul: update tests 2026-01-03 22:44:53 -05:00