summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2023-01-12 10:36:18 +0100
committerGitHub <noreply@github.com>2023-01-12 10:36:18 +0100
commita5dedfe2609f22bbf497efd1ef457ba8487ce7c8 (patch)
tree7dc3f32261d73da5efc94c10505dbd625b5b32ba /main
parent0e4e782ada0bdd4ef19415f82a6373e2d79f7ecc (diff)
parent9802914f9793b6888cc70e3d7f0d815bdd5188bb (diff)
Merge pull request #70731 from smix8/navigationserver_performance_monitor_4.x
Add NavigationServer Performance Monitor
Diffstat (limited to 'main')
-rw-r--r--main/main.cpp10
-rw-r--r--main/performance.cpp53
-rw-r--r--main/performance.h12
3 files changed, 74 insertions, 1 deletions
diff --git a/main/main.cpp b/main/main.cpp
index 190cdf3151..5736aedfe5 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -2964,6 +2964,7 @@ bool Main::is_iterating() {
// For performance metrics.
static uint64_t physics_process_max = 0;
static uint64_t process_max = 0;
+static uint64_t navigation_process_max = 0;
bool Main::iteration() {
//for now do not error on this
@@ -2992,6 +2993,7 @@ bool Main::iteration() {
uint64_t physics_process_ticks = 0;
uint64_t process_ticks = 0;
+ uint64_t navigation_process_ticks = 0;
frame += ticks_elapsed;
@@ -3029,6 +3031,12 @@ bool Main::iteration() {
}
NavigationServer3D::get_singleton()->process(physics_step * time_scale);
+ uint64_t navigation_begin = OS::get_singleton()->get_ticks_usec();
+
+ NavigationServer3D::get_singleton()->process(physics_step * time_scale);
+
+ navigation_process_ticks = MAX(navigation_process_ticks, OS::get_singleton()->get_ticks_usec() - navigation_begin); // keep the largest one for reference
+ navigation_process_max = MAX(OS::get_singleton()->get_ticks_usec() - navigation_begin, navigation_process_max);
message_queue->flush();
@@ -3108,8 +3116,10 @@ bool Main::iteration() {
Engine::get_singleton()->_fps = frames;
performance->set_process_time(USEC_TO_SEC(process_max));
performance->set_physics_process_time(USEC_TO_SEC(physics_process_max));
+ performance->set_navigation_process_time(USEC_TO_SEC(navigation_process_max));
process_max = 0;
physics_process_max = 0;
+ navigation_process_max = 0;
frame %= 1000000;
frames = 0;
diff --git a/main/performance.cpp b/main/performance.cpp
index c2624c708f..448ddd0e96 100644
--- a/main/performance.cpp
+++ b/main/performance.cpp
@@ -36,6 +36,7 @@
#include "scene/main/node.h"
#include "scene/main/scene_tree.h"
#include "servers/audio_server.h"
+#include "servers/navigation_server_3d.h"
#include "servers/physics_server_2d.h"
#include "servers/physics_server_3d.h"
#include "servers/rendering_server.h"
@@ -54,6 +55,7 @@ void Performance::_bind_methods() {
BIND_ENUM_CONSTANT(TIME_FPS);
BIND_ENUM_CONSTANT(TIME_PROCESS);
BIND_ENUM_CONSTANT(TIME_PHYSICS_PROCESS);
+ BIND_ENUM_CONSTANT(TIME_NAVIGATION_PROCESS);
BIND_ENUM_CONSTANT(MEMORY_STATIC);
BIND_ENUM_CONSTANT(MEMORY_STATIC_MAX);
BIND_ENUM_CONSTANT(MEMORY_MESSAGE_BUFFER_MAX);
@@ -74,7 +76,15 @@ void Performance::_bind_methods() {
BIND_ENUM_CONSTANT(PHYSICS_3D_COLLISION_PAIRS);
BIND_ENUM_CONSTANT(PHYSICS_3D_ISLAND_COUNT);
BIND_ENUM_CONSTANT(AUDIO_OUTPUT_LATENCY);
-
+ BIND_ENUM_CONSTANT(NAVIGATION_ACTIVE_MAPS);
+ BIND_ENUM_CONSTANT(NAVIGATION_REGION_COUNT);
+ BIND_ENUM_CONSTANT(NAVIGATION_AGENT_COUNT);
+ BIND_ENUM_CONSTANT(NAVIGATION_LINK_COUNT);
+ BIND_ENUM_CONSTANT(NAVIGATION_POLYGON_COUNT);
+ BIND_ENUM_CONSTANT(NAVIGATION_EDGE_COUNT);
+ BIND_ENUM_CONSTANT(NAVIGATION_EDGE_MERGE_COUNT);
+ BIND_ENUM_CONSTANT(NAVIGATION_EDGE_CONNECTION_COUNT);
+ BIND_ENUM_CONSTANT(NAVIGATION_EDGE_FREE_COUNT);
BIND_ENUM_CONSTANT(MONITOR_MAX);
}
@@ -93,6 +103,7 @@ String Performance::get_monitor_name(Monitor p_monitor) const {
"time/fps",
"time/process",
"time/physics_process",
+ "time/navigation_process",
"memory/static",
"memory/static_max",
"memory/msg_buf_max",
@@ -113,6 +124,15 @@ String Performance::get_monitor_name(Monitor p_monitor) const {
"physics_3d/collision_pairs",
"physics_3d/islands",
"audio/driver/output_latency",
+ "navigation/active_maps",
+ "navigation/regions",
+ "navigation/agents",
+ "navigation/links",
+ "navigation/polygons",
+ "navigation/edges",
+ "navigation/edges_merged",
+ "navigation/edges_connected",
+ "navigation/edges_free",
};
@@ -127,6 +147,8 @@ double Performance::get_monitor(Monitor p_monitor) const {
return _process_time;
case TIME_PHYSICS_PROCESS:
return _physics_process_time;
+ case TIME_NAVIGATION_PROCESS:
+ return _navigation_process_time;
case MEMORY_STATIC:
return Memory::get_mem_usage();
case MEMORY_STATIC_MAX:
@@ -167,6 +189,24 @@ double Performance::get_monitor(Monitor p_monitor) const {
return PhysicsServer3D::get_singleton()->get_process_info(PhysicsServer3D::INFO_ISLAND_COUNT);
case AUDIO_OUTPUT_LATENCY:
return AudioServer::get_singleton()->get_output_latency();
+ case NAVIGATION_ACTIVE_MAPS:
+ return NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_ACTIVE_MAPS);
+ case NAVIGATION_REGION_COUNT:
+ return NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_REGION_COUNT);
+ case NAVIGATION_AGENT_COUNT:
+ return NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_AGENT_COUNT);
+ case NAVIGATION_LINK_COUNT:
+ return NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_LINK_COUNT);
+ case NAVIGATION_POLYGON_COUNT:
+ return NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_POLYGON_COUNT);
+ case NAVIGATION_EDGE_COUNT:
+ return NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_EDGE_COUNT);
+ case NAVIGATION_EDGE_MERGE_COUNT:
+ return NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_EDGE_MERGE_COUNT);
+ case NAVIGATION_EDGE_CONNECTION_COUNT:
+ return NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_EDGE_CONNECTION_COUNT);
+ case NAVIGATION_EDGE_FREE_COUNT:
+ return NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_EDGE_FREE_COUNT);
default: {
}
@@ -182,6 +222,7 @@ Performance::MonitorType Performance::get_monitor_type(Monitor p_monitor) const
MONITOR_TYPE_QUANTITY,
MONITOR_TYPE_TIME,
MONITOR_TYPE_TIME,
+ MONITOR_TYPE_TIME,
MONITOR_TYPE_MEMORY,
MONITOR_TYPE_MEMORY,
MONITOR_TYPE_MEMORY,
@@ -202,6 +243,12 @@ Performance::MonitorType Performance::get_monitor_type(Monitor p_monitor) const
MONITOR_TYPE_QUANTITY,
MONITOR_TYPE_QUANTITY,
MONITOR_TYPE_TIME,
+ MONITOR_TYPE_QUANTITY,
+ MONITOR_TYPE_QUANTITY,
+ MONITOR_TYPE_QUANTITY,
+ MONITOR_TYPE_QUANTITY,
+ MONITOR_TYPE_QUANTITY,
+ MONITOR_TYPE_QUANTITY,
};
@@ -216,6 +263,10 @@ void Performance::set_physics_process_time(double p_pt) {
_physics_process_time = p_pt;
}
+void Performance::set_navigation_process_time(double p_pt) {
+ _navigation_process_time = p_pt;
+}
+
void Performance::add_custom_monitor(const StringName &p_id, const Callable &p_callable, const Vector<Variant> &p_args) {
ERR_FAIL_COND_MSG(has_custom_monitor(p_id), "Custom monitor with id '" + String(p_id) + "' already exists.");
_monitor_map.insert(p_id, MonitorCall(p_callable, p_args));
diff --git a/main/performance.h b/main/performance.h
index 14695ab5a3..34162b2da9 100644
--- a/main/performance.h
+++ b/main/performance.h
@@ -50,6 +50,7 @@ class Performance : public Object {
double _process_time;
double _physics_process_time;
+ double _navigation_process_time;
class MonitorCall {
Callable _callable;
@@ -69,6 +70,7 @@ public:
TIME_FPS,
TIME_PROCESS,
TIME_PHYSICS_PROCESS,
+ TIME_NAVIGATION_PROCESS,
MEMORY_STATIC,
MEMORY_STATIC_MAX,
MEMORY_MESSAGE_BUFFER_MAX,
@@ -89,6 +91,15 @@ public:
PHYSICS_3D_COLLISION_PAIRS,
PHYSICS_3D_ISLAND_COUNT,
AUDIO_OUTPUT_LATENCY,
+ NAVIGATION_ACTIVE_MAPS,
+ NAVIGATION_REGION_COUNT,
+ NAVIGATION_AGENT_COUNT,
+ NAVIGATION_LINK_COUNT,
+ NAVIGATION_POLYGON_COUNT,
+ NAVIGATION_EDGE_COUNT,
+ NAVIGATION_EDGE_MERGE_COUNT,
+ NAVIGATION_EDGE_CONNECTION_COUNT,
+ NAVIGATION_EDGE_FREE_COUNT,
MONITOR_MAX
};
@@ -105,6 +116,7 @@ public:
void set_process_time(double p_pt);
void set_physics_process_time(double p_pt);
+ void set_navigation_process_time(double p_pt);
void add_custom_monitor(const StringName &p_id, const Callable &p_callable, const Vector<Variant> &p_args);
void remove_custom_monitor(const StringName &p_id);