diff options
| author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2019-09-05 16:34:36 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-05 16:34:36 +0200 |
| commit | 768d637a1bc94a0a6a9b4ea2eb50e2c8197be3ab (patch) | |
| tree | 98a1a70f28e15fd7ae9b71d273267ded905a2542 /core/io/multiplayer_api.h | |
| parent | 8bcf6ca95317329242e954a71047ce1183cfe5f8 (diff) | |
| parent | 8244f535cd2a610f40bb22894ac87d08c48a0601 (diff) | |
| download | redot-engine-768d637a1bc94a0a6a9b4ea2eb50e2c8197be3ab.tar.gz | |
Merge pull request #31870 from JFonS/add_network_profiler
Add network profiler
Diffstat (limited to 'core/io/multiplayer_api.h')
| -rw-r--r-- | core/io/multiplayer_api.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/core/io/multiplayer_api.h b/core/io/multiplayer_api.h index 5258dde5d7..b824456e0f 100644 --- a/core/io/multiplayer_api.h +++ b/core/io/multiplayer_api.h @@ -38,6 +38,16 @@ class MultiplayerAPI : public Reference { GDCLASS(MultiplayerAPI, Reference); +public: + struct ProfilingInfo { + ObjectID node; + String node_path; + int incoming_rpc; + int incoming_rset; + int outgoing_rpc; + int outgoing_rset; + }; + private: //path sent caches struct PathSentCache { @@ -55,6 +65,23 @@ private: Map<int, NodeInfo> nodes; }; +#ifdef DEBUG_ENABLED + struct BandwidthFrame { + uint32_t timestamp; + int packet_size; + }; + + int bandwidth_incoming_pointer; + Vector<BandwidthFrame> bandwidth_incoming_data; + int bandwidth_outgoing_pointer; + Vector<BandwidthFrame> bandwidth_outgoing_data; + Map<ObjectID, ProfilingInfo> profiler_frame_data; + bool profiling; + + void _init_node_profile(ObjectID p_node); + int _get_bandwidth_usage(const Vector<BandwidthFrame> &p_buffer, int p_pointer); +#endif + Ref<NetworkedMultiplayerPeer> network_peer; int rpc_sender_id; Set<int> connected_peers; @@ -130,6 +157,13 @@ public: void set_allow_object_decoding(bool p_enable); bool is_object_decoding_allowed() const; + void profiling_start(); + void profiling_end(); + + int get_profiling_frame(ProfilingInfo *r_info); + int get_incoming_bandwidth_usage(); + int get_outgoing_bandwidth_usage(); + MultiplayerAPI(); ~MultiplayerAPI(); }; |
