mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 00:13:30 +00:00
Add network profiler
This commit is contained in:
parent
979e772947
commit
8244f535cd
10 changed files with 579 additions and 1 deletions
|
@ -33,6 +33,7 @@
|
|||
#include "core/io/marshalls.h"
|
||||
#include "core/project_settings.h"
|
||||
#include "core/ustring.h"
|
||||
#include "editor_network_profiler.h"
|
||||
#include "editor_node.h"
|
||||
#include "editor_profiler.h"
|
||||
#include "editor_settings.h"
|
||||
|
@ -977,7 +978,20 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
|
|||
profiler->add_frame_metric(metric, false);
|
||||
else
|
||||
profiler->add_frame_metric(metric, true);
|
||||
|
||||
} else if (p_msg == "network_profile") {
|
||||
int frame_size = 6;
|
||||
for (int i = 0; i < p_data.size(); i += frame_size) {
|
||||
MultiplayerAPI::ProfilingInfo pi;
|
||||
pi.node = p_data[i + 0];
|
||||
pi.node_path = p_data[i + 1];
|
||||
pi.incoming_rpc = p_data[i + 2];
|
||||
pi.incoming_rset = p_data[i + 3];
|
||||
pi.outgoing_rpc = p_data[i + 4];
|
||||
pi.outgoing_rset = p_data[i + 5];
|
||||
network_profiler->add_node_frame_data(pi);
|
||||
}
|
||||
} else if (p_msg == "network_bandwidth") {
|
||||
network_profiler->set_bandwidth(p_data[0], p_data[1]);
|
||||
} else if (p_msg == "kill_me") {
|
||||
|
||||
editor->call_deferred("stop_child_process");
|
||||
|
@ -1193,6 +1207,10 @@ void ScriptEditorDebugger::_notification(int p_what) {
|
|||
if (profiler->is_profiling()) {
|
||||
_profiler_activate(true);
|
||||
}
|
||||
|
||||
if (network_profiler->is_profiling()) {
|
||||
_network_profiler_activate(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1412,6 +1430,25 @@ void ScriptEditorDebugger::_profiler_activate(bool p_enable) {
|
|||
}
|
||||
}
|
||||
|
||||
void ScriptEditorDebugger::_network_profiler_activate(bool p_enable) {
|
||||
|
||||
if (!connection.is_valid())
|
||||
return;
|
||||
|
||||
if (p_enable) {
|
||||
Array msg;
|
||||
msg.push_back("start_network_profiling");
|
||||
ppeer->put_var(msg);
|
||||
print_verbose("Starting network profiling.");
|
||||
|
||||
} else {
|
||||
Array msg;
|
||||
msg.push_back("stop_network_profiling");
|
||||
ppeer->put_var(msg);
|
||||
print_verbose("Ending network profiling.");
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptEditorDebugger::_profiler_seeked() {
|
||||
|
||||
if (!connection.is_valid() || !connection->is_connected_to_host())
|
||||
|
@ -2000,6 +2037,7 @@ void ScriptEditorDebugger::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("_expand_errors_list"), &ScriptEditorDebugger::_expand_errors_list);
|
||||
ClassDB::bind_method(D_METHOD("_collapse_errors_list"), &ScriptEditorDebugger::_collapse_errors_list);
|
||||
ClassDB::bind_method(D_METHOD("_profiler_activate"), &ScriptEditorDebugger::_profiler_activate);
|
||||
ClassDB::bind_method(D_METHOD("_network_profiler_activate"), &ScriptEditorDebugger::_network_profiler_activate);
|
||||
ClassDB::bind_method(D_METHOD("_profiler_seeked"), &ScriptEditorDebugger::_profiler_seeked);
|
||||
ClassDB::bind_method(D_METHOD("_clear_errors_list"), &ScriptEditorDebugger::_clear_errors_list);
|
||||
|
||||
|
@ -2218,6 +2256,13 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
|
|||
profiler->connect("break_request", this, "_profiler_seeked");
|
||||
}
|
||||
|
||||
{ //network profiler
|
||||
network_profiler = memnew(EditorNetworkProfiler);
|
||||
network_profiler->set_name(TTR("Network Profiler"));
|
||||
tabs->add_child(network_profiler);
|
||||
network_profiler->connect("enable_profiling", this, "_network_profiler_activate");
|
||||
}
|
||||
|
||||
{ //monitors
|
||||
|
||||
HSplitContainer *hsp = memnew(HSplitContainer);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue