feat: add basic profiling/metrics system (#104)

- Add ProfilingMetrics struct to track performance data
- Track frame time (current and 60-frame rolling average)
- Calculate FPS from average frame time
- Count draw calls, UI elements, and visible elements per frame
- Track total runtime and current frame number
- PyScene counts elements during render
- Expose metrics via mcrfpy.getMetrics() returning dict

This provides basic performance monitoring capabilities for
identifying bottlenecks and optimizing rendering performance.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
John McCardle 2025-07-06 12:15:32 -04:00
commit f23aa784f2
5 changed files with 80 additions and 3 deletions

View file

@ -72,8 +72,16 @@ void PyScene::render()
// Render in sorted order (no need to copy anymore)
for (auto e: *ui_elements)
{
if (e)
if (e) {
// Track metrics
game->metrics.uiElements++;
if (e->visible) {
game->metrics.visibleElements++;
// Count this as a draw call (each visible element = 1+ draw calls)
game->metrics.drawCalls++;
}
e->render();
}
}
// Display is handled by GameEngine