Add objects replication and RPC stats table to Network Profiler

This commit is contained in:
Wojtek Figat
2023-09-26 10:33:12 +02:00
parent da47088250
commit 6621e70ae7
10 changed files with 343 additions and 34 deletions

View File

@@ -3,14 +3,17 @@
#if COMPILE_WITH_PROFILER
#include "ProfilingTools.h"
#include "Engine/Core/Types/Pair.h"
#include "Engine/Engine/Engine.h"
#include "Engine/Engine/Time.h"
#include "Engine/Engine/EngineService.h"
#include "Engine/Graphics/GPUDevice.h"
#include "Engine/Networking/NetworkInternal.h"
ProfilingTools::MainStats ProfilingTools::Stats;
Array<ProfilingTools::ThreadStats, InlinedAllocation<64>> ProfilingTools::EventsCPU;
Array<ProfilerGPU::Event> ProfilingTools::EventsGPU;
Array<ProfilingTools::NetworkEventStat> ProfilingTools::EventsNetwork;
class ProfilingToolsService : public EngineService
{
@@ -120,6 +123,40 @@ void ProfilingToolsService::Update()
frame.Extract(ProfilingTools::EventsGPU);
}
// Get the last events from networking runtime
{
auto& networkEvents = ProfilingTools::EventsNetwork;
networkEvents.Resize(NetworkInternal::ProfilerEvents.Count());
int32 i = 0;
for (const auto& e : NetworkInternal::ProfilerEvents)
{
const auto& src = e.Value;
auto& dst = networkEvents[i++];
dst.Count = src.Count;
dst.DataSize = src.DataSize;
dst.MessageSize = src.MessageSize;
dst.Receivers = src.Receivers;
const StringAnsiView& typeName = e.Key.First.GetType().Fullname;
uint64 len = Math::Min<uint64>(typeName.Length(), ARRAY_COUNT(dst.Name) - 10);
Platform::MemoryCopy(dst.Name, typeName.Get(), len);
const StringAnsiView& name = e.Key.Second;
if (name.HasChars())
{
uint64 pos = len;
dst.Name[pos++] = ':';
dst.Name[pos++] = ':';
len = Math::Min<uint64>(name.Length(), ARRAY_COUNT(dst.Name) - pos - 1);
Platform::MemoryCopy(dst.Name + pos, name.Get(), len);
dst.Name[pos + len] = 0;
}
else
{
dst.Name[len] = 0;
}
}
NetworkInternal::ProfilerEvents.Clear();
}
#if 0
// Print CPU events to the log
{
@@ -173,6 +210,7 @@ void ProfilingToolsService::Dispose()
ProfilingTools::EventsCPU.Clear();
ProfilingTools::EventsCPU.SetCapacity(0);
ProfilingTools::EventsGPU.SetCapacity(0);
ProfilingTools::EventsNetwork.SetCapacity(0);
}
bool ProfilingTools::GetEnabled()
@@ -184,6 +222,7 @@ void ProfilingTools::SetEnabled(bool enabled)
{
ProfilerCPU::Enabled = enabled;
ProfilerGPU::Enabled = enabled;
NetworkInternal::EnableProfiling = enabled;
}
#endif