summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorMax Hilbrunner <mhilbrunner@users.noreply.github.com>2018-05-26 17:31:52 +0200
committerGitHub <noreply@github.com>2018-05-26 17:31:52 +0200
commit16974d81d8ce03ea744871757c627aa2f9a0dfc7 (patch)
treeaab407bfb0e23c28b29e9732cdfcd6952bc178d1 /main
parent603af8055accedf63f80d11c0b44febb62ce7d5e (diff)
parent228ae60a63df4190028a34648290417982c0d268 (diff)
Merge pull request #18998 from Calinou/customizable-performance-reporting-rate
Make the performance reporting update frequency customizable
Diffstat (limited to 'main')
-rw-r--r--main/main.cpp18
-rw-r--r--main/main.h2
2 files changed, 14 insertions, 6 deletions
diff --git a/main/main.cpp b/main/main.cpp
index 70713e2dd8..ad49e1f5bd 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -1706,7 +1706,7 @@ bool Main::start() {
uint64_t Main::last_ticks = 0;
uint64_t Main::target_ticks = 0;
-uint32_t Main::frames = 0;
+Array Main::frame_times = Array();
uint32_t Main::frame = 0;
bool Main::force_redraw_requested = false;
@@ -1825,10 +1825,19 @@ bool Main::iteration() {
script_debugger->idle_poll();
}
- frames++;
Engine::get_singleton()->_idle_frames++;
- if (frame > 1000000) {
+ // FPS counter
+ frame_times.push_back(ticks);
+ int frames = frame_times.size();
+
+ while (frame_times.size() > 0 && (int)frame_times.get(0) <= ticks - 1000000) {
+ frame_times.pop_front();
+ }
+
+ int update_frequency = MAX(1, (int)GLOBAL_GET("debug/settings/performance/update_frequency_msec"));
+
+ if (frame > update_frequency * 1000) {
if (editor || project_manager) {
if (print_fps) {
@@ -1844,8 +1853,7 @@ bool Main::iteration() {
idle_process_max = 0;
physics_process_max = 0;
- frame %= 1000000;
- frames = 0;
+ frame %= update_frequency * 1000;
}
if (fixed_fps != -1)
diff --git a/main/main.h b/main/main.h
index c20592bf3b..8f264d7720 100644
--- a/main/main.h
+++ b/main/main.h
@@ -44,7 +44,7 @@ class Main {
static void print_help(const char *p_binary);
static uint64_t last_ticks;
static uint64_t target_ticks;
- static uint32_t frames;
+ static Array frame_times;
static uint32_t frame;
static bool force_redraw_requested;