perf(window): ring buffer for CRAFTER_TIMING frame times (#44) #76
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Catcrafts/Crafter.Graphics!76
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "claude/issue-44"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Replaces the
std::vector<nanoseconds> frameTimes+erase(begin())in theCRAFTER_TIMINGframe loop with a fixed-sizestd::array<nanoseconds, 100>ring buffer (head index + count).
The old code memmoved ~99 elements left on every frame once the 100-entry
window filled.
LogTimingcomputes order-independent sum/avg/min/max, so thering's write order is irrelevant to the reported statistics — a ring buffer is
a drop-in replacement.
Scope is
LOW/Smallas filed; behindCRAFTER_TIMINGonly, so shippingbuilds are unaffected.
Changes
interfaces/Crafter.Graphics-Window.cppm:frameTimesis now astd::arrayplusframeTimesHead/frameTimesCount, with aframeTimeCapacityconstant.implementations/Crafter.Graphics-Window.cpp: push writes into the ring andadvances head;
LogTimingiterates the firstframeTimesCountvalid entries.Testing
crafter-build test— 3 passed (shipping, non-timing configuration).crafter-build -- --timing.Note: pre-existing
--timingbuild breakage (out of scope)The
--timingbuild does not currently link onmaster, independently ofthis change:
implementations/Crafter.Graphics-Window.cpp:647and:841reference
renderTimings/renderer/RenderingElement, none of which aredeclared in the window module anymore (confirmed by stashing this change and
rebuilding
master— identical 3 errors). This looks like leftover code from arenderer refactor and is unrelated to the frame-time buffer; fixing it is a
separate concern. My edited lines produce no errors.
Resolves #44
🤖 Generated with Claude Code