From 47ee0bcee25aff219a921daf2d90359629b7120f Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Tue, 12 Apr 2022 00:23:22 +0200 Subject: [PATCH] Hide the first `--print-fps` outputs after the engine has started The first 2 or 3 prints are inaccurate since the engine has just started at that point. (cherry picked from commit 2d56dfb746fb05c8cab090e4b411b1987e990fca) --- main/main.cpp | 16 +++++++++++----- main/main.h | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/main/main.cpp b/main/main.cpp index dfce25548..bc841c37f 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -2122,6 +2122,7 @@ bool Main::start() { uint64_t Main::last_ticks = 0; uint32_t Main::frames = 0; +uint32_t Main::hide_print_fps_attempts = 3; uint32_t Main::frame = 0; bool Main::force_redraw_requested = false; int Main::iterating = 0; @@ -2300,12 +2301,17 @@ bool Main::iteration() { Engine::get_singleton()->_idle_frames++; if (frame > 1000000) { - if (editor || project_manager) { - if (print_fps) { - print_line(vformat("Editor FPS: %d (%s mspf)", frames, rtos(1000.0 / frames).pad_decimals(2))); + // Wait a few seconds before printing FPS, as FPS reporting just after the engine has started is inaccurate. + if (hide_print_fps_attempts == 0) { + if (editor || project_manager) { + if (print_fps) { + print_line(vformat("Editor FPS: %d (%s mspf)", frames, rtos(1000.0 / frames).pad_decimals(2))); + } + } else if (print_fps || GLOBAL_GET("debug/settings/stdout/print_fps")) { + print_line(vformat("Project FPS: %d (%s mspf)", frames, rtos(1000.0 / frames).pad_decimals(2))); } - } else if (GLOBAL_GET("debug/settings/stdout/print_fps") || print_fps) { - print_line(vformat("Project FPS: %d (%s mspf)", frames, rtos(1000.0 / frames).pad_decimals(2))); + } else { + hide_print_fps_attempts--; } Engine::get_singleton()->_fps = frames; diff --git a/main/main.h b/main/main.h index 9ac4b58cd..65c86d521 100644 --- a/main/main.h +++ b/main/main.h @@ -37,6 +37,7 @@ class Main { static void print_help(const char *p_binary); static uint64_t last_ticks; + static uint32_t hide_print_fps_attempts; static uint32_t frames; static uint32_t frame; static bool force_redraw_requested;