mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 10:37:07 +01:00
feat(debug): debug.perflog writes the times of the renderer to perf.txt while the game runs
debug.perflog <seconds> in eu07.ini, 0 (off) by default. Once the scenery is loaded, every so many seconds the tables of the debug panel of the renderer (info_times(): its times on the CPU and the GPU by the pass; info_stats(): its counts) are appended to perf.txt in the working folder of the game, beside the log, each headed with the number of frames since the last write, the longest of them and how many took over 25 and over 50 ms, which the averages of the tables don't show. The file is emptied at the first write of a run. Parsed in ConfigParseDebug() and written to the log with the other settings. Off, nothing changes. It showed the stutter of the TreeGenX trees (the sky occlusion gathering them on the main thread) and a stall while the memory of a 16 GB card filled up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -102,6 +102,41 @@ void end_timer_period()
|
||||
timer_period_set = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
// debug.perflog: every so many seconds the tables of the debug panel of the renderer, its times on the cpu and the gpu by the pass
|
||||
// and its counts of the draws, appended to perf.txt beside the log (emptied at the first write of the run), to tell what slows the
|
||||
// frame down while the game runs
|
||||
void write_performance_log()
|
||||
{
|
||||
if ((Global.debug_perflog <= 0.f) || (GfxRenderer == nullptr) || (false == simulation::is_ready))
|
||||
return;
|
||||
// the frames between two writes: the longest and how many took long, which the averages of the tables don't show
|
||||
static auto last{std::chrono::steady_clock::now()};
|
||||
static auto next{last + std::chrono::seconds(5)};
|
||||
static bool started{false};
|
||||
static double longest{0.0};
|
||||
static int slow{0};
|
||||
static int stalled{0};
|
||||
static int frames{0};
|
||||
auto const now{std::chrono::steady_clock::now()};
|
||||
auto const frame{std::chrono::duration<double, std::milli>(now - last).count()};
|
||||
last = now;
|
||||
longest = std::max(longest, frame);
|
||||
slow += (frame > 25.0 ? 1 : 0);
|
||||
stalled += (frame > 50.0 ? 1 : 0);
|
||||
++frames;
|
||||
if (now < next)
|
||||
return;
|
||||
next = now + std::chrono::milliseconds(static_cast<long long>(Global.debug_perflog * 1000.f));
|
||||
std::ofstream out{"perf.txt", started ? std::ios::app : std::ios::trunc};
|
||||
started = true;
|
||||
out << std::format("==== {:.1f} s, {} frames, the longest {:.1f} ms, {} over 25 ms, {} over 50 ms\n", Timer::GetTime(), frames, longest, slow, stalled);
|
||||
longest = 0.0;
|
||||
slow = 0;
|
||||
stalled = 0;
|
||||
frames = 0;
|
||||
out << std::format("==== {:.1f} s\n", Timer::GetTime()) << GfxRenderer->info_times() << "\n" << GfxRenderer->info_stats() << "\n";
|
||||
}
|
||||
} // namespace
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -825,6 +860,7 @@ int eu07_application::run()
|
||||
m_network->update();
|
||||
|
||||
Timer::subsystem.mainloop_total.stop();
|
||||
write_performance_log();
|
||||
// fpslimit: wait for the next frame's slot (eu07/maszyna#416)
|
||||
if (auto const nextframe{framepacer.next_frame(frame_pacer::clock::now(), Global.minframetime)})
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user