summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Locurcio <hugo.locurcio@hugo.pro>2018-05-17 02:02:35 +0200
committerHugo Locurcio <hugo.locurcio@hugo.pro>2018-05-18 11:49:21 +0200
commit228ae60a63df4190028a34648290417982c0d268 (patch)
tree3ed8c257c7a40c8c3ca0d62e980e1d8b3b3823bb
parent942e0c483247af1e84b7992be48f8ef6317d45c6 (diff)
Make the performance reporting update frequency customizable
The default update frequency has been changed from 1000ms to 250ms.
-rw-r--r--core/project_settings.cpp1
-rw-r--r--core/script_debugger_remote.cpp4
-rw-r--r--core/script_language.cpp2
-rw-r--r--core/script_language.h2
-rw-r--r--main/main.cpp18
-rw-r--r--main/main.h2
6 files changed, 21 insertions, 8 deletions
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index ac4a4b7d15..ef485cb3b2 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -1071,6 +1071,7 @@ ProjectSettings::ProjectSettings() {
GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_mode", 2);
GLOBAL_DEF("debug/settings/profiler/max_functions", 16384);
+ GLOBAL_DEF("debug/settings/performance/update_frequency_msec", 250);
//assigning here, because using GLOBAL_GET on every block for compressing can be slow
Compression::zstd_long_distance_matching = GLOBAL_DEF("compression/formats/zstd/long_distance_matching", false);
diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp
index 75bcedbbc8..7a30a33c67 100644
--- a/core/script_debugger_remote.cpp
+++ b/core/script_debugger_remote.cpp
@@ -854,7 +854,7 @@ void ScriptDebuggerRemote::idle_poll() {
if (performance) {
uint64_t pt = OS::get_singleton()->get_ticks_msec();
- if (pt - last_perf_time > 1000) {
+ if (pt - last_perf_time > update_frequency) {
last_perf_time = pt;
int max = performance->get("MONITOR_MAX");
@@ -1081,7 +1081,7 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() :
eh.userdata = this;
add_error_handler(&eh);
- profile_info.resize(CLAMP(int(ProjectSettings::get_singleton()->get("debug/settings/profiler/max_functions")), 128, 65535));
+ profile_info.resize(CLAMP(int(GLOBAL_GET("debug/settings/profiler/max_functions")), 128, 65535));
profile_info_ptrs.resize(profile_info.size());
}
diff --git a/core/script_language.cpp b/core/script_language.cpp
index 1dab58e29e..ce9b138bb2 100644
--- a/core/script_language.cpp
+++ b/core/script_language.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "script_language.h"
+#include "project_settings.h"
ScriptLanguage *ScriptServer::_languages[MAX_LANGUAGES];
int ScriptServer::_language_count = 0;
@@ -283,6 +284,7 @@ ScriptDebugger::ScriptDebugger() {
lines_left = -1;
depth = -1;
break_lang = NULL;
+ update_frequency = GLOBAL_GET("debug/settings/performance/update_frequency_msec");
}
bool PlaceHolderScriptInstance::set(const StringName &p_name, const Variant &p_value) {
diff --git a/core/script_language.h b/core/script_language.h
index b4c55cac9e..64c6f2eb81 100644
--- a/core/script_language.h
+++ b/core/script_language.h
@@ -352,6 +352,8 @@ class ScriptDebugger {
public:
typedef void (*RequestSceneTreeMessageFunc)(void *);
+ int update_frequency;
+
struct LiveEditFuncs {
void *udata;
diff --git a/main/main.cpp b/main/main.cpp
index c287bc81cb..9b62081378 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -1729,7 +1729,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;
@@ -1848,10 +1848,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) {
@@ -1867,8 +1876,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;