fix(metrics): report counters Python can actually observe
get_metrics() returned 0 for draw_calls, ui_elements, visible_elements and every grid counter. Two distinct defects behind one symptom. Ordering. draw_calls/ui_elements/visible_elements WERE incremented, in PyScene::render() -- but render runs at step 6 of the frame, after every Python callback, while the counters were zeroed at step 1. A script calling get_metrics() from a timer or scene update was structurally incapable of ever observing a nonzero value. Dead code. grid_cells_rendered, entities_rendered, total_entities, grid_render_time and entity_render_time were never incremented ANYWHERE in src/ -- the increments were lost in the GridView/chunk refactor and only fovOverlayTime survived. They are re-instrumented in UIGridView::render(). Fix both by splitting the metrics along the seam that actually exists: rendering is orthogonal to simulation and costs zero clock time (a screenshot draws arbitrary state without advancing time). So render counters are cleared and published by the render pass (beginRender/endRender, in both doFrame and the on-demand renderScene), and simulation timings by the sim pass (beginSimFrame/endSimFrame). get_metrics() reads the published values, so a step()-only run cannot wipe the counters from the last render, and a render cannot disturb the clock. Riders found while in here: - ScopedTimer ASSIGNS, so with two grid views on screen the second view's time silently replaced the first's. Added ScopedAccumTimer for per-frame totals accumulated across objects; fovOverlayTime had this bug already. - fps was inflated for the first 60 frames: frameTimeHistory is zero-filled but the mean always divided by the full 60. Now divides by frames actually seen. - frame_time is milliseconds; the docstring said seconds. Fixed the docstring, not the value -- the Gauntlet already reads it as ms. closes #341
This commit is contained in:
parent
464af6a549
commit
c72ab22999
7 changed files with 332 additions and 34 deletions
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue