McRogueFace/tests/benchmarks
John McCardle 182da6230d Fast path for hot property getters: stop importing mcrfpy per call; closes #331
Replace the PyImport_ImportModule("mcrfpy") + PyObject_GetAttrString +
full type-call ceremony with direct &mcrfpydef::PyXType references
(safe since all PyTypeObjects are inline C++17 definitions) in every
non-init call site:

- UIDrawable: get_pos/get_origin/get_global_pos now allocate via
  PyVector(...).pyObject(); set_pos/set_origin check the Vector type
  directly.
- GridLayers: ColorLayer at/subscript wrap via PyColor(...).pyObject()
  (also fixes a module refcount leak per read); set/fill/fill_rect,
  draw_fov/apply_perspective color parsing, Entity/Texture/HeightMap
  instance checks, and TileLayer texture get/set use direct type refs.
- UIGrid init layers=, add_layer/remove_layer/layer(), Grid.layers
  getter: direct ColorLayer/TileLayer type refs.
- PyTileSetFile.to_texture, PyLdtkProject.tileset: direct type refs.

Benchmark (tests/benchmarks/issue_331_property_read_bench.py, 200k
reads, release build):
  frame.pos              559 ns -> 65 ns/read  (8.6x)
  frame.origin           571 ns -> 64 ns/read  (8.9x)
  frame.global_position  589 ns -> 66 ns/read  (8.9x)
  ColorLayer.at          608 ns -> 262 ns/read (2.3x)

Test suite: 304/304 pass.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DK5DHgRDNGmpN54vnEHAot
2026-07-08 21:58:50 -04:00
..
baseline Gauntlet #340: menu layout polish; commit first captured baseline; closes #340 2026-07-02 20:48:22 -04:00
gauntlet Gauntlet #340: menu layout polish; commit first captured baseline; closes #340 2026-07-02 20:48:22 -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
issue_331_property_read_bench.py Fast path for hot property getters: stop importing mcrfpy per call; closes #331 2026-07-08 21:58:50 -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