feat: Add work_time_ms to benchmark logging for load analysis
Track actual work time separately from frame time to determine system load percentage: - work_time_ms: Time spent doing actual work before display() - sleep_time = frame_time_ms - work_time_ms This allows calculating load percentage: load% = (work_time / frame_time) * 100 Example at 60fps with light load: - frame_time: 16.67ms, work_time: 2ms - load: 12%, sleep: 14.67ms 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
a7fef2aeb6
commit
8583db7225
5 changed files with 16 additions and 3 deletions
|
|
@ -16,6 +16,7 @@ void BenchmarkLogger::recordFrame(const ProfilingMetrics& metrics) {
|
|||
frame.frame_time_ms = metrics.frameTime;
|
||||
frame.fps = metrics.fps;
|
||||
|
||||
frame.work_time_ms = metrics.workTime;
|
||||
frame.grid_render_ms = metrics.gridRenderTime;
|
||||
frame.entity_render_ms = metrics.entityRenderTime;
|
||||
frame.python_time_ms = metrics.pythonScriptTime;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ struct BenchmarkFrame {
|
|||
int fps;
|
||||
|
||||
// Detailed timing breakdown
|
||||
float work_time_ms; // Actual work time (frame_time - sleep_time)
|
||||
float grid_render_ms;
|
||||
float entity_render_ms;
|
||||
float python_time_ms;
|
||||
|
|
@ -172,6 +173,7 @@ public:
|
|||
file << " \"timestamp_ms\": " << std::fixed << std::setprecision(3) << f.timestamp_ms << ",\n";
|
||||
file << " \"frame_time_ms\": " << std::setprecision(3) << f.frame_time_ms << ",\n";
|
||||
file << " \"fps\": " << f.fps << ",\n";
|
||||
file << " \"work_time_ms\": " << std::setprecision(3) << f.work_time_ms << ",\n";
|
||||
file << " \"grid_render_ms\": " << std::setprecision(3) << f.grid_render_ms << ",\n";
|
||||
file << " \"entity_render_ms\": " << std::setprecision(3) << f.entity_render_ms << ",\n";
|
||||
file << " \"python_time_ms\": " << std::setprecision(3) << f.python_time_ms << ",\n";
|
||||
|
|
|
|||
|
|
@ -291,6 +291,9 @@ void GameEngine::run()
|
|||
ImGui::SFML::Render(*window);
|
||||
}
|
||||
|
||||
// Record work time before display (which may block for vsync/framerate limit)
|
||||
metrics.workTime = clock.getElapsedTime().asSeconds() * 1000.0f;
|
||||
|
||||
// Display the frame
|
||||
if (headless) {
|
||||
headless_renderer->display();
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ struct ProfilingMetrics {
|
|||
float fovOverlayTime = 0.0f; // Time spent rendering FOV overlays (ms)
|
||||
float pythonScriptTime = 0.0f; // Time spent in Python callbacks (ms)
|
||||
float animationTime = 0.0f; // Time spent updating animations (ms)
|
||||
float workTime = 0.0f; // Total work time before display/sleep (ms)
|
||||
|
||||
// Grid-specific metrics
|
||||
int gridCellsRendered = 0; // Number of grid cells drawn this frame
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue