Print profiler at end of session

This commit is contained in:
sfan5 2024-04-11 12:42:12 +02:00
parent 72eeb9fecb
commit 4027e08cc8
3 changed files with 21 additions and 8 deletions

@ -258,6 +258,13 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)
}
} // Menu-game loop
// If profiler was enabled print it one last time
if (g_settings->getFloat("profiler_print_interval") > 0) {
infostream << "Profiler:" << std::endl;
g_profiler->print(infostream);
g_profiler->clear();
}
assert(g_menucloudsmgr->getReferenceCount() == 1);
g_menucloudsmgr->drop();
g_menucloudsmgr = nullptr;

@ -1904,7 +1904,8 @@ void Game::updateProfilers(const RunStats &stats, const FpsControl &draw_times,
g_settings->getFloat("profiler_print_interval");
bool print_to_log = true;
if (profiler_print_interval == 0) {
// Update game UI anyway but don't log
if (profiler_print_interval <= 0) {
print_to_log = false;
profiler_print_interval = 3;
}
@ -1919,12 +1920,12 @@ void Game::updateProfilers(const RunStats &stats, const FpsControl &draw_times,
g_profiler->clear();
}
// Update update graphs
// Update graphs
g_profiler->graphAdd("Time non-rendering [us]",
draw_times.busy_time - stats.drawtime);
g_profiler->graphAdd("Sleep [us]", draw_times.sleep_time);
g_profiler->graphAdd("FPS", 1.0f / dtime);
g_profiler->graphSet("FPS", 1.0f / dtime);
}
void Game::updateStats(RunStats *stats, const FpsControl &draw_times,

@ -4096,9 +4096,8 @@ void dedicated_server_loop(Server &server, bool &kill)
/*
Profiler
*/
if (profiler_print_interval != 0) {
if(m_profiler_interval.step(steplen, profiler_print_interval))
{
if (profiler_print_interval > 0) {
if (m_profiler_interval.step(steplen, profiler_print_interval)) {
infostream << "Profiler:" << std::endl;
g_profiler->print(infostream);
g_profiler->clear();
@ -4112,6 +4111,12 @@ void dedicated_server_loop(Server &server, bool &kill)
ServerList::sendAnnounce(ServerList::AA_DELETE,
server.m_bind_addr.getPort());
#endif
if (profiler_print_interval > 0) {
infostream << "Profiler:" << std::endl;
g_profiler->print(infostream);
g_profiler->clear();
}
}
/*