UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
NetworkProfiler.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4 NetworkProfiler.h: network profiling support.
5=============================================================================*/
6
7#pragma once
8
9#include "CoreMinimal.h"
10#include "Engine/EngineTypes.h"
11#include "IPAddress.h"
12#include "Containers/BitArray.h"
15#include "Misc/ScopeLock.h"
17
18class AActor;
19class FOutBunch;
20class UNetConnection;
21struct FURL;
22
23#if USE_NETWORK_PROFILER
24
26
27#define NETWORK_PROFILER( x ) \
28 if ( GNetworkProfiler.IsTrackingEnabled() ) \
29 { \
30 CSV_SCOPED_TIMING_STAT_EXCLUSIVE(NetworkProfiler); \
31 x; \
32 }
33
36
38
39/*=============================================================================
40 Network profiler header.
41=============================================================================*/
42
44{
45private:
47 uint32 Magic;
50
52 FString Tag;
54 FString GameName;
56 FString URL;
57
58public:
61
63 void Reset(const FURL& InURL);
64
66 FString GetURL() const { return URL; }
67
76};
77
78/*=============================================================================
79 FNetworkProfiler
80=============================================================================*/
81
86{
87private:
88
90 friend struct FNetworkProfilerCVarHelper;
91
94
97
100
103
106
109
113 bool bIsTrackingEnabled;
116
118 FNetworkProfilerHeader CurrentHeader;
119
122
125
128
130
132 struct FSendBunchInfo
133 {
134 uint16 ChannelIndex;
138
140 : ChannelIndex(0)
142 , NumHeaderBits(0)
143 , NumPayloadBits(0) {}
144
146 : ChannelIndex(InChannelIndex)
150 };
151
154
156 struct FQueuedRPCInfo
157 {
158 UNetConnection* Connection;
159 UObject* TargetObject;
165
167 : Connection(nullptr)
168 , TargetObject(nullptr)
169 , ActorNameIndex(0)
171 , NumHeaderBits(0)
173 , NumFooterBits(0) {}
174 };
175
177
184 ENGINE_API int32 GetNameTableIndex( const FString& Name );
185
192 ENGINE_API int32 GetAddressTableIndex( const FString& Address );
193
195
196 // Used with FScopedIgnoreReplicateProperties.
198
199 // Set of names that correspond to Object's whose top level property names have been exported.
201
203
212
221
229
237
245
246
248 FString NextFileName;
249
250public:
255
262
264 ENGINE_API void SetNextFileName(const FString& FileName);
265
270
275
276
287
300
307 ENGINE_API void FlushQueuedRPCs( UNetConnection* Connection, UObject* TargetObject );
308
316 ENGINE_API void TrackSocketSend( const FString& SocketDesc, const void* Data, uint16 BytesSent );
317
331 const FString& SocketDesc,
332 const void* Data,
333 uint16 BytesSent,
334 uint16 NumPacketIdBits,
335 uint16 NumBunchBits,
336 uint16 NumAckBits,
337 uint16 NumPaddingBits,
338 UNetConnection* Connection );
339
349 const FString& SocketDesc,
350 const void* Data,
351 uint16 BytesSent,
352 uint16 NumPacketIdBits,
353 uint16 NumBunchBits,
354 uint16 NumAckBits,
355 uint16 NumPaddingBits,
356 UNetConnection* Connection );
357
358
366
377
383 ENGINE_API void PopSendBunch( UNetConnection* Connection );
384
391
397 ENGINE_API void TrackReplicateActor( const AActor* Actor, FReplicationFlags RepFlags, uint32 Cycles, UNetConnection* Connection );
398
409
420 template<typename T, typename ProjectionType>
422 {
424 {
425 UE::TScopeLock ScopeLock(CriticalSection);
426
427 FString ObjectName = GetNameSafe(Object);
429
430 if (!ExportedObjects.Contains(ObjectName))
431 {
433 PropertyNameExportData.Reserve(2 + (NumProperties * 2));
435
436 PropertyNameAr.SerializeIntPacked(NumProperties);
438 {
440 PropertyNameAr.SerializeIntPacked(PropertyNameIndex);
441 }
442 }
443
445 }
446 }
447
455
463
470 ENGINE_API void TrackEvent( const FString& EventName, const FString& EventDescription, UNetConnection* Connection );
471
481
488
495
503
511
519
526
536 ENGINE_API bool Exec( UWorld * InWorld, const TCHAR* Cmd, FOutputDevice & Ar );
537
538 bool inline IsTrackingEnabled() const { return bIsTrackingEnabled || bShouldTrackingBeEnabled; }
540
543
546};
547
550
551#define NETWORK_PROFILER_IGNORE_PROPERTY_SCOPE const FNetworkProfilerScopedIgnoreReplicateProperties _NetProfilePrivate_IgnoreScope;
552
558{
560 {
561 ++GNetworkProfiler.IgnorePropertyCount;
562 }
563
565 {
566 --GNetworkProfiler.IgnorePropertyCount;
567 }
568
569private:
570
573};
574
575#else // USE_NETWORK_PROFILER
576
577#define NETWORK_PROFILER(x)
578#define NETWORK_PROFILER_IGNORE_PROPERTY_SCOPE
579
580#endif
FString GetNameSafe(const FField *InField)
Definition Field.h:1230
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define CSV_DECLARE_CATEGORY_EXTERN(CategoryName)
Definition CsvProfiler.h:79
#define DECLARE_MULTICAST_DELEGATE_OneParam(DelegateName, Param1Type)
Definition DelegateCombinations.h:49
FArchive & operator<<(FArchive &Ar, FEnvQueryDebugProfileData::FStep &Data)
Definition EnvQueryTypes.cpp:489
::FCriticalSection FTransactionallySafeCriticalSection
Definition TransactionallySafeCriticalSection.h:16
uint16_t uint16
Definition binka_ue_file_header.h:7
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Actor.h:257
Definition Archive.h:1208
Definition MemoryWriter.h:101
Definition DataBunch.h:24
Definition OutputDevice.h:133
Definition UnrealType.h:174
Definition Array.h:670
Definition UnrealString.h.inl:34
Definition SharedPointer.h:692
Definition ScopeLock.h:21
Definition Class.h:2476
Definition NetConnection.h:284
Definition Object.h:95
Definition World.h:918
@ URL
Definition TokenizedMessage.h:47
Version
Definition NNEModelData.cpp:15
@ Exec
This function is executable from the command line.
Definition ObjectMacros.h:962
Definition EngineTypes.h:3601
Definition TimerHandle.h:12
Definition EngineBaseTypes.h:799