UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
CsvProfiler.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
8#pragma once
9
10#include "Async/Future.h"
11#include "Async/TaskGraphFwd.h"
12#include "Containers/Array.h"
13#include "Containers/Map.h"
14#include "Containers/Queue.h"
17#include "CoreTypes.h"
18#include "Delegates/Delegate.h"
19#include "HAL/PlatformCrt.h"
22#include "Misc/EnumClassFlags.h"
23#include "Misc/Guid.h"
31#include "Templates/UniquePtr.h"
34#include "UObject/NameTypes.h"
35#include "AutoRTFM.h"
36#include <atomic>
37
38class FCsvProfiler;
39class FEvent;
40class FScopedCsvStat;
42struct FCsvDeclaredStat;
43
44
45#if CSV_PROFILER
46 // Helpers
47 #define CSV_CATEGORY_INDEX(CategoryName) (_GCsvCategory_##CategoryName.Index)
48 #define CSV_CATEGORY_INDEX_GLOBAL (0)
49
50 // Categories
51 #define CSV_DEFINE_CATEGORY(CategoryName,bDefaultValue) FCsvCategory _GCsvCategory_##CategoryName(TEXT(#CategoryName),bDefaultValue)
52 #define CSV_DEFINE_CATEGORY_MODULE(Module_API,CategoryName,bDefaultValue) FCsvCategory Module_API _GCsvCategory_##CategoryName(TEXT(#CategoryName),bDefaultValue)
53 #define CSV_DECLARE_CATEGORY_EXTERN(CategoryName) extern FCsvCategory _GCsvCategory_##CategoryName
54 #define CSV_DECLARE_CATEGORY_MODULE_EXTERN(Module_API,CategoryName) extern Module_API FCsvCategory _GCsvCategory_##CategoryName
55
56 // Events
57 #define CSV_EVENT(Category, Format, ...) \
58 FCsvProfiler::RecordEventf( CSV_CATEGORY_INDEX(Category), Format, ##__VA_ARGS__ ); \
59 TRACE_BOOKMARK(TEXT(PREPROCESSOR_TO_STRING(Category)) TEXT("/") Format, ##__VA_ARGS__)
60
61 #define CSV_EVENT_GLOBAL(Format, ...) \
62 FCsvProfiler::RecordEventf( CSV_CATEGORY_INDEX_GLOBAL, Format, ##__VA_ARGS__ ); \
63 TRACE_BOOKMARK(Format, ##__VA_ARGS__)
64
65 // Metadata
66 #define CSV_METADATA(Key,Value) FCsvProfiler::SetMetadata( Key, Value )
67 #define CSV_NON_PERSISTENT_METADATA(Key,Value) FCsvProfiler::SetNonPersistentMetadata( Key, Value )
68
69 // Minimal stat macros (emitted even when CSV_PROFILER_MINIMAL is 1)
70 // IMPORTANT: Only a handful of key stats are expected to use these. Do not add more without very good reason!
71 #define CSV_CUSTOM_STAT_MINIMAL(Category,StatName,Value,Op) FCsvProfiler::RecordCustomStatMinimal(#StatName, CSV_CATEGORY_INDEX(Category), Value, Op);
72 #define CSV_CUSTOM_STAT_MINIMAL_GLOBAL(StatName,Value,Op) FCsvProfiler::RecordCustomStatMinimal(#StatName, CSV_CATEGORY_INDEX_GLOBAL, Value, Op);
73
74#else
75 #define CSV_CATEGORY_INDEX(CategoryName) (0)
76 #define CSV_CATEGORY_INDEX_GLOBAL (0)
77 #define CSV_DEFINE_CATEGORY(CategoryName,bDefaultValue)
78 #define CSV_DEFINE_CATEGORY_MODULE(Module_API,CategoryName,bDefaultValue)
79 #define CSV_DECLARE_CATEGORY_EXTERN(CategoryName)
80 #define CSV_DECLARE_CATEGORY_MODULE_EXTERN(Module_API,CategoryName)
81 #define CSV_EVENT(Category, Format, ...)
82 #define CSV_EVENT_GLOBAL(Format, ...)
83 #define CSV_METADATA(Key,Value)
84 #define CSV_NON_PERSISTENT_METADATA(Key,Value)
85 #define CSV_CUSTOM_STAT_MINIMAL(Category,StatName,Value,Op)
86 #define CSV_CUSTOM_STAT_MINIMAL_GLOBAL(StatName,Value,Op)
87#endif
88
89// Stat macros. These are disabled if CSV_PROFILER_MINIMAL is 1
90#if CSV_PROFILER && !CSV_PROFILER_MINIMAL
91 // Helpers
92 #define CSV_STAT_FNAME(StatName) (_GCsvStat_##StatName.Name)
93
94 // Timing stats - no up-front definition
95 #define CSV_SCOPED_TIMING_STAT(Category,StatName) \
96 TRACE_CSV_PROFILER_INLINE_STAT(#StatName, CSV_CATEGORY_INDEX(Category)); \
97 FScopedCsvStat _ScopedCsvStat_ ## StatName (#StatName, CSV_CATEGORY_INDEX(Category), "CSV_"#StatName);
98 #define CSV_SCOPED_TIMING_STAT_GLOBAL(StatName) \
99 TRACE_CSV_PROFILER_INLINE_STAT(#StatName, CSV_CATEGORY_INDEX_GLOBAL); \
100 FScopedCsvStat _ScopedCsvStat_ ## StatName (#StatName, CSV_CATEGORY_INDEX_GLOBAL, "CSV_"#StatName);
101 #define CSV_SCOPED_TIMING_STAT_CONDITIONAL(Category,StatName, Condition) \
102 TRACE_CSV_PROFILER_INLINE_STAT(#StatName, CSV_CATEGORY_INDEX(Category)); \
103 FScopedCsvStatConditional _ScopedCsvStat_ ## StatName (#StatName, CSV_CATEGORY_INDEX(Category), Condition, "CSV_"#StatName);
104 #define CSV_SCOPED_TIMING_STAT_EXCLUSIVE(StatName) \
105 TRACE_CSV_PROFILER_INLINE_STAT_EXCLUSIVE(#StatName); \
106 FScopedCsvStatExclusive _ScopedCsvStatExclusive_ ## StatName (#StatName, "CSV_"#StatName);
107 #define CSV_SCOPED_TIMING_STAT_EXCLUSIVE_CONDITIONAL(StatName,Condition) \
108 TRACE_CSV_PROFILER_INLINE_STAT_EXCLUSIVE(#StatName); \
109 FScopedCsvStatExclusiveConditional _ScopedCsvStatExclusive_ ## StatName (#StatName,Condition, "CSV_"#StatName);
110 #define CSV_SCOPED_TIMING_STAT_RECURSIVE(Category,StatName) \
111 TRACE_CSV_PROFILER_INLINE_STAT(#StatName, CSV_CATEGORY_INDEX(Category)); \
112 static thread_local int32 _ScopedCsvStatRecursive_EntryCount_ ## StatName = 0; \
113 FScopedCsvStatRecursive _ScopedCsvStatRecursive_ ## StatName (_ScopedCsvStatRecursive_EntryCount_ ## StatName, #StatName, CSV_CATEGORY_INDEX(Category), "CSV_"#StatName);
114 #define CSV_SCOPED_TIMING_STAT_RECURSIVE_CONDITIONAL(Category,StatName,Condition) \
115 TRACE_CSV_PROFILER_INLINE_STAT(#StatName, CSV_CATEGORY_INDEX(Category)); \
116 static thread_local int32 _ScopedCsvStatRecursive_EntryCount_ ## StatName = 0; \
117 FScopedCsvStatRecursiveConditional _ScopedCsvStatRecursive_ ## StatName (_ScopedCsvStatRecursive_EntryCount_ ## StatName, #StatName, CSV_CATEGORY_INDEX(Category), Condition, "CSV_"#StatName);
118
119 // Waits
120 #define CSV_SCOPED_WAIT(WaitTime) FScopedCsvWaitConditional _ScopedCsvWait(WaitTime>0 && FCsvProfiler::IsWaitTrackingEnabledOnCurrentThread());
121 #define CSV_SCOPED_WAIT_CONDITIONAL(Condition) FScopedCsvWaitConditional _ScopedCsvWait(Condition);
122
123 #define CSV_SCOPED_SET_WAIT_STAT(StatName) \
124 TRACE_CSV_PROFILER_INLINE_STAT_EXCLUSIVE("EventWait/"#StatName); \
125 FScopedCsvSetWaitStat _ScopedCsvSetWaitStat ## StatName("EventWait/"#StatName, "CsvEventWait/"#StatName, "CsvEventWait/"#StatName" (Non-CP)");
126
127 #define CSV_SCOPED_SET_WAIT_STAT_IGNORE() FScopedCsvSetWaitStat _ScopedCsvSetWaitStat ## StatName();
128
129 // Custom Stats
130 #define CSV_CUSTOM_STAT(Category,StatName,Value,Op) \
131 UE_AUTORTFM_OPEN \
132 { \
133 TRACE_CSV_PROFILER_INLINE_STAT(#StatName, CSV_CATEGORY_INDEX(Category)); \
134 FCsvProfiler::RecordCustomStat(#StatName, CSV_CATEGORY_INDEX(Category), Value, Op); \
135 };
136 #define CSV_CUSTOM_STAT_GLOBAL(StatName,Value,Op) \
137 UE_AUTORTFM_OPEN \
138 { \
139 TRACE_CSV_PROFILER_INLINE_STAT(#StatName, CSV_CATEGORY_INDEX_GLOBAL); \
140 FCsvProfiler::RecordCustomStat(#StatName, CSV_CATEGORY_INDEX_GLOBAL, Value, Op); \
141 };
142
143 // Stats declarations/definitions (for FName stats)
144 #define CSV_DEFINE_STAT(Category,StatName) FCsvDeclaredStat _GCsvStat_##StatName((TCHAR*)TEXT(#StatName), CSV_CATEGORY_INDEX(Category));
145 #define CSV_DEFINE_STAT_GLOBAL(StatName) FCsvDeclaredStat _GCsvStat_##StatName((TCHAR*)TEXT(#StatName), CSV_CATEGORY_INDEX_GLOBAL);
146 #define CSV_DECLARE_STAT_EXTERN(Category,StatName) extern FCsvDeclaredStat _GCsvStat_##StatName
147 #define CSV_CUSTOM_STAT_DEFINED(StatName,Value,Op) FCsvProfiler::RecordCustomStat(_GCsvStat_##StatName.Name, _GCsvStat_##StatName.CategoryIndex, Value, Op);
148#else
149 #define CSV_STAT_FNAME(StatName) NAME_None
150 #define CSV_SCOPED_TIMING_STAT(Category,StatName)
151 #define CSV_SCOPED_TIMING_STAT_GLOBAL(StatName)
152 #define CSV_SCOPED_TIMING_STAT_EXCLUSIVE(StatName)
153 #define CSV_SCOPED_TIMING_STAT_EXCLUSIVE_CONDITIONAL(StatName,Condition)
154 #define CSV_SCOPED_TIMING_STAT_RECURSIVE(Category,StatName)
155 #define CSV_SCOPED_TIMING_STAT_RECURSIVE_CONDITIONAL(Category,StatName,Condition)
156 #define CSV_SCOPED_WAIT(WaitTime)
157 #define CSV_SCOPED_WAIT_CONDITIONAL(Condition)
158 #define CSV_SCOPED_SET_WAIT_STAT(StatName)
159 #define CSV_SCOPED_SET_WAIT_STAT_IGNORE()
160 #define CSV_CUSTOM_STAT(Category,StatName,Value,Op)
161 #define CSV_CUSTOM_STAT_GLOBAL(StatName,Value,Op)
162 #define CSV_DEFINE_STAT(Category,StatName)
163 #define CSV_DEFINE_STAT_GLOBAL(StatName)
164 #define CSV_DECLARE_STAT_EXTERN(Category,StatName)
165 #define CSV_CUSTOM_STAT_DEFINED(StatName,Value,Op)
166#endif
167
168
169#if CSV_PROFILER
170
174class FName;
176
177enum class ECsvCustomStatOp : uint8
178{
179 Set,
180 Min,
181 Max,
183};
184
185enum class ECsvCommandType : uint8
186{
187 Start,
188 Stop,
189 Count
190};
191
192struct FCsvCategory;
193
194struct FCsvDeclaredStat
195{
198 , CategoryIndex(InCategoryIndex)
199 {
201 }
202
203 FName Name;
204 uint32 CategoryIndex;
205};
206
207enum class ECsvProfilerFlags
208{
209 None = 0,
211 CompressOutput = 2
212};
214
216{
218 : CommandType(ECsvCommandType::Count)
219 , FrameRequested(-1)
220 , Value(-1)
221 {}
222
224 : CommandType(InCommandType)
225 , FrameRequested(InFrameRequested)
226 , Value(InValue)
228 , Filename(InFilename)
229 , Flags(InFlags)
230 {}
231
233 : CommandType(InCommandType)
234 , FrameRequested(InFrameRequested)
235 , Completion(MoveTemp(InCompletion))
236 , Future(InFuture)
237 {}
238
239 ECsvCommandType CommandType;
240 uint32 FrameRequested;
242 FString DestinationFolder;
243 FString Filename;
245 TPromise<FString>* Completion;
247};
248
249//
250// Persistent custom stats
251//
253{
254 Float,
255 Int,
256 Count
257};
258
260{
261public:
264 {
265 }
266
268 {
269 return StatType;
270 }
271protected:
272 FName Name;
273 uint32 CategoryIndex;
274 bool bResetEachFrame;
276};
277
278
279template <class T>
281{
282 friend struct FCsvPersistentCustomStats;
283private:
284 std::atomic<T> Value;
285};
286
287
288template <>
290{
291 friend struct FCsvPersistentCustomStats;
292public:
295 , Value(0.0f)
296 {}
297
298 float Add(float Rhs)
299 {
300 float Previous = Value.load(std::memory_order_consume);
301 float Desired = Previous + Rhs;
302 while (!Value.compare_exchange_weak(Previous, Desired, std::memory_order_release, std::memory_order_consume))
303 {
304 Desired = Previous + Rhs;
305 }
306 return Desired;
307 }
308 float Sub(float Rhs)
309 {
310 return Add(-Rhs);
311 }
312 void Set(float NewVal)
313 {
314 return Value.store(NewVal, std::memory_order_relaxed);
315 }
316 float GetValue()
317 {
318 return Value.load();
319 }
320 static ECsvPersistentCustomStatType GetClassStatType() { return ECsvPersistentCustomStatType::Float; }
321protected:
322 std::atomic<float> Value;
323};
324
325
326template <>
328{
329 friend struct FCsvPersistentCustomStats;
330public:
333 , Value(0)
334 {}
335
336 int32 Add(int32 Rhs)
337 {
338 return Value.fetch_add(Rhs, std::memory_order_relaxed);
339 }
340 int32 Sub(int32 Rhs)
341 {
342 return Value.fetch_sub(Rhs, std::memory_order_relaxed);
343 }
344 void Set(int32 NewVal)
345 {
346 Value.store(NewVal, std::memory_order_relaxed);
347 }
349 {
350 return Value.load();
351 }
352 static ECsvPersistentCustomStatType GetClassStatType() { return ECsvPersistentCustomStatType::Int; }
353protected:
354 std::atomic<int> Value;
355};
356
357
361class FCsvProfiler
362{
363 friend class FCsvProfilerProcessingThread;
364 friend class FCsvProfilerThreadData;
365 friend struct FCsvCategory;
366public:
367 FCsvProfiler();
369 static CORE_API FCsvProfiler* Get();
370
371 CORE_API void Init();
372
375 CORE_API static void BeginStat(const char* StatName, uint32 CategoryIndex, const char* NamedEventName = nullptr);
376 CORE_API static void BeginStat(const FName& StatName, uint32 CategoryIndex);
377 CORE_API static void EndStat(const char* StatName, uint32 CategoryIndex);
378 CORE_API static void EndStat(const FName& StatName, uint32 CategoryIndex);
379
380 CORE_API static void BeginExclusiveStat(const char * StatName, const char* NamedEventName = nullptr);
381 CORE_API static void EndExclusiveStat(const char * StatName);
382
383 CORE_API static void RecordCustomStat(const char * StatName, uint32 CategoryIndex, float Value, const ECsvCustomStatOp CustomStatOp);
384 CORE_API static void RecordCustomStat(const FName& StatName, uint32 CategoryIndex, float Value, const ECsvCustomStatOp CustomStatOp);
385 CORE_API static void RecordCustomStat(const char* StatName, uint32 CategoryIndex, double Value, const ECsvCustomStatOp CustomStatOp);
386 CORE_API static void RecordCustomStat(const FName& StatName, uint32 CategoryIndex, double Value, const ECsvCustomStatOp CustomStatOp);
387 CORE_API static void RecordCustomStat(const char * StatName, uint32 CategoryIndex, int32 Value, const ECsvCustomStatOp CustomStatOp);
388 CORE_API static void RecordCustomStat(const FName& StatName, uint32 CategoryIndex, int32 Value, const ECsvCustomStatOp CustomStatOp);
389
390 CORE_API static void RecordEndOfPipeCustomStat(const FName& StatName, uint32 CategoryIndex, double Value, const ECsvCustomStatOp CustomStatOp);
391
392 // Warning: Don't use this unless the stat is one of a handful of key stats that we want to capture in CSV_PROFILER_MINIMAL mode
393 CORE_API static void RecordCustomStatMinimal(const char* StatName, uint32 CategoryIndex, float Value, const ECsvCustomStatOp CustomStatOp);
394 CORE_API static void RecordCustomStatMinimal(const char* StatName, uint32 CategoryIndex, int32 Value, const ECsvCustomStatOp CustomStatOp);
395 CORE_API static void RecordCustomStatMinimal(const char* StatName, uint32 CategoryIndex, double Value, const ECsvCustomStatOp CustomStatOp);
396
397 CORE_API static void RecordEvent(int32 CategoryIndex, const FString& EventText);
398 CORE_API static void RecordEventAtFrameStart(int32 CategoryIndex, const FString& EventText);
399 CORE_API static void RecordEventAtTimestamp(int32 CategoryIndex, const FString& EventText, uint64 Cycles64);
400
402 CORE_API static void SetMetadata(const TCHAR* Key, const TCHAR* Value);
404 CORE_API static void SetNonPersistentMetadata(const TCHAR* Key, const TCHAR* Value);
405
406 static CORE_API int32 RegisterCategory(const FString& Name, bool bEnableByDefault, bool bIsGlobal);
407 static CORE_API int32 GetCategoryIndex(const FString& Name);
408
409 template <typename FmtType, typename... Types>
410 inline static void RecordEventf(int32 CategoryIndex, const FmtType& Fmt, Types... Args)
411 {
413 {
414 static_assert(TIsArrayOrRefOfTypeByPredicate<FmtType, TIsCharEncodingCompatibleWithTCHAR>::Value, "Formatting string must be a TCHAR array.");
415 static_assert((TIsValidVariadicFunctionArg<Types>::Value && ...), "Invalid argument(s) passed to FCsvProfiler::RecordEventf");
416 RecordEventfInternal(CategoryIndex, (const TCHAR*)Fmt, Args...);
417 };
418 }
419
420 CORE_API static void BeginSetWaitStat(const char* StatName, const char* FormattedStatName, const char* FormattedStatNameNonCP);
421 CORE_API static void EndSetWaitStat();
422
423 CORE_API static void BeginWait();
424 CORE_API static void EndWait();
425
427 CORE_API bool IsCapturing() const;
429 CORE_API bool IsWritingFile() const;
430 CORE_API bool IsEndCapturePending() const;
431
432 CORE_API int32 GetCaptureFrameNumber() const;
435 CORE_API const FGuid& GetCsvID() const;
436
437 CORE_API bool EnableCategoryByString(const FString& CategoryName) const;
438 CORE_API void EnableCategoryByIndex(uint32 CategoryIndex, bool bEnable) const;
439 CORE_API bool IsCategoryEnabled(uint32 CategoryIndex) const;
440
442 CORE_API void BeginFrame();
443 CORE_API void EndFrame();
444
446 CORE_API void BeginCapture(int InNumFramesToCapture = -1,
447 const FString& InDestinationFolder = FString(),
448 const FString& InFilename = FString(),
449 ECsvProfilerFlags InFlags = ECsvProfilerFlags::None);
450
457
459 CORE_API void OnEndFramePostFork();
460
462 CORE_API void BeginFrameRT();
463 CORE_API void EndFrameRT();
464
465 CORE_API void BeginFrameEOP();
466
468
469 FString GetOutputFilename() const { return OutputFilename; }
471
473
475
479
483
487
490
491 DECLARE_MULTICAST_DELEGATE_OneParam(FOnCSVProfileFinished, const FString& /*Filename */);
493
497
499 DECLARE_MULTICAST_DELEGATE_TwoParams(FOnCSVEvent, const FString& /* CategoryName */, const FString& /* EventText */);
501
503 {
505 }
506
508 {
510 }
511
512 // Persistent custom stat methods. These are pre-registered custom stats whose value can persist over multiple frames
513 // They are lower overhead than normal custom stats because accumulate ops don't require memory allocation
516
517private:
518 CORE_API static void VARARGS RecordEventfInternal(int32 CategoryIndex, const TCHAR* Fmt, ...);
519
520 enum class EMetadataPersistenceType : int8
521 {
524 };
525
526 void SetMetadataInternal(const TCHAR* Key, const TCHAR* Value, bool bSanitize=true, EMetadataPersistenceType PersistenceType = EMetadataPersistenceType::Persistent);
527
528 void FinalizeCsvFile();
529
531
533
535
536 int32 NumFramesToCapture;
537 int32 CaptureFrameNumber;
540
542
545
548
549 double CaptureStartTime;
550
551 FString OutputFilename;
554
556 FThreadSafeCounter IsShuttingDown;
557
562
564
566
574
575 std::atomic<uint32> RenderThreadId{ 0 };
576 std::atomic<uint32> RHIThreadId{ 0 };
577};
578
579class FScopedCsvStat
580{
581public:
582 FScopedCsvStat(const char * InStatName, uint32 InCategoryIndex, const char * InNamedEventName = nullptr)
583 : StatName(InStatName)
584 , CategoryIndex(InCategoryIndex)
585 {
586 UE_AUTORTFM_OPEN{ FCsvProfiler::BeginStat(StatName, CategoryIndex, InNamedEventName); };
587 AutoRTFM::PushOnAbortHandler(this, [SN = StatName, CI = CategoryIndex](){ FCsvProfiler::EndStat(SN, CI); });
588 }
589
591 {
592 AutoRTFM::PopOnAbortHandler(this);
593 UE_AUTORTFM_OPEN{ FCsvProfiler::EndStat(StatName, CategoryIndex); };
594 }
595 const char * StatName;
596 uint32 CategoryIndex;
597};
598
600{
601public:
603 : StatName(InStatName)
604 , CategoryIndex(InCategoryIndex)
605 , bCondition(bInCondition)
606 {
607 if (bCondition)
608 {
609 FCsvProfiler::BeginStat(StatName, CategoryIndex, InNamedEventName);
610 }
611 }
612
614 {
615 if (bCondition)
616 {
617 FCsvProfiler::EndStat(StatName, CategoryIndex);
618 }
619 }
620
621 const char* StatName;
622 uint32 CategoryIndex;
623 bool bCondition;
624};
625
627{
628public:
629 FScopedCsvStatExclusive(const char * InStatName, const char* InNamedEventName = nullptr)
630 : StatName(InStatName)
631 {
632 UE_AUTORTFM_OPEN{ FCsvProfiler::BeginExclusiveStat(StatName, InNamedEventName); };
633 AutoRTFM::PushOnAbortHandler(this, [SN = StatName](){ FCsvProfiler::EndExclusiveStat(SN); });
634 }
635
637 {
638 AutoRTFM::PopOnAbortHandler(this);
639 UE_AUTORTFM_OPEN{ FCsvProfiler::EndExclusiveStat(StatName); };
640 }
641 const char * StatName;
642};
643
645{
646public:
647 FScopedCsvStatExclusiveConditional(const char * InStatName, bool bInCondition, const char* InNamedEventName = nullptr)
648 : StatName(InStatName)
649 , bCondition(bInCondition)
650 {
651 if (bCondition)
652 {
653 FCsvProfiler::BeginExclusiveStat(StatName, InNamedEventName);
654 }
655 }
656
658 {
659 if (bCondition)
660 {
661 FCsvProfiler::EndExclusiveStat(StatName);
662 }
663 }
664 const char * StatName;
665 bool bCondition;
666};
667
669{
670 const char* StatName;
671 uint32 CategoryIndex;
673public:
675 : StatName(InStatName)
676 , CategoryIndex(InCategoryIndex)
678 {
679 ++EntryCounter; // this needs to happen before BeginStat in case BeginStat causes reentry
680 if (EntryCounter == 1)
681 {
682 FCsvProfiler::BeginStat(StatName, CategoryIndex, InNamedEventName);
683 }
684 }
686 {
687 if (EntryCounter == 1)
688 {
689 FCsvProfiler::EndStat(StatName, CategoryIndex);
690 }
691 --EntryCounter;
692 }
693};
694
696{
697 const char* StatName;
698 uint32 CategoryIndex;
700 bool bCondition;
701public:
703 : StatName(InStatName)
704 , CategoryIndex(InCategoryIndex)
706 , bCondition(bInCondition)
707 {
708 if (bCondition)
709 {
710 ++EntryCounter; // this needs to happen before BeginStat in case BeginStat causes reentry
711 if (EntryCounter == 1)
712 {
713 FCsvProfiler::BeginStat(StatName, CategoryIndex, InNamedEventName);
714 }
715 }
716 }
718 {
719 if (bCondition)
720 {
721 if (EntryCounter == 1)
722 {
723 FCsvProfiler::EndStat(StatName, CategoryIndex);
724 }
725 --EntryCounter;
726 }
727 }
728};
729
731{
732public:
734 : bCondition(bInCondition)
735 {
736 if (bCondition)
737 {
738 FCsvProfiler::BeginWait();
739 }
740 }
741
743 {
744 if (bCondition)
745 {
746 FCsvProfiler::EndWait();
747 }
748 }
749 bool bCondition;
750};
751
752
754{
755public:
757 const char* InStatName = nullptr,
758 const char* InFormattedStatName = nullptr,
759 const char* InFormattedStatNameNonCP = nullptr)
760 : StatName(InStatName)
763 {
764 FCsvProfiler::BeginSetWaitStat(StatName, FormattedStatName, FormattedStatNameNonCP);
765 }
766
768 {
769 FCsvProfiler::EndSetWaitStat();
770 }
771
772 const char* StatName;
773 const char* FormattedStatName;
774 const char* FormattedStatNameNonCP;
775};
776
777struct FCsvCategory
778{
779 FCsvCategory() : Index(-1) {}
780 FCsvCategory(const TCHAR* CategoryString, bool bDefaultValue, bool bIsGlobal = false)
781 {
783 Index = FCsvProfiler::RegisterCategory(Name, bDefaultValue, bIsGlobal);
784 }
785
787 FString Name;
788};
789
790
792
793
794#endif //CSV_PROFILER
#define VARARGS
Definition AndroidPlatform.h:134
FPlatformTypes::int8 int8
An 8-bit signed integer.
Definition Platform.h:1121
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
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define TRACE_CSV_PROFILER_DECLARED_STAT(...)
Definition CsvProfilerTrace.h:98
#define CSV_CATEGORY_INDEX_GLOBAL
Definition CsvProfiler.h:76
#define CSV_DECLARE_CATEGORY_MODULE_EXTERN(Module_API, CategoryName)
Definition CsvProfiler.h:80
#define DECLARE_MULTICAST_DELEGATE_TwoParams(DelegateName, Param1Type, Param2Type)
Definition DelegateCombinations.h:58
#define DECLARE_MULTICAST_DELEGATE(DelegateName)
Definition DelegateCombinations.h:23
#define DECLARE_MULTICAST_DELEGATE_OneParam(DelegateName, Param1Type)
Definition DelegateCombinations.h:49
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
void Init()
Definition LockFreeList.h:4
@ Stop
Definition PrecomputedVolumetricLightmapStreaming.cpp:26
USkinnedMeshComponent float
Definition SkinnedMeshComponent.h:60
::FCriticalSection FTransactionallySafeCriticalSection
Definition TransactionallySafeCriticalSection.h:16
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Event.h:21
Definition NameTypes.h:617
Definition ThreadSafeCounter.h:14
Definition Array.h:670
Definition UnrealString.h.inl:34
Definition Future.h:541
Definition Queue.h:48
Definition Future.h:490
FGameThreadAudioCommandQueue CommandQueue
Definition AudioThread.cpp:222
T::FDataType GetValue(const UBlackboardComponent &Blackboard, const FName &Name, FBlackboard::FKey &InOutCachedKey, const typename T::FDataType &DefaultValue)
Definition ValueOrBBKey.h:51
FORCEINLINE T * Get(const FObjectPtr &ObjectPtr)
Definition ObjectPtr.h:426
@ Start
Definition GeoEnum.h:100
FORCEINLINE UE_STRING_CLASS RhsType && Rhs
Definition String.cpp.inl:718
U16 Index
Definition radfft.cpp:71
Definition Guid.h:109
Definition IsArrayOrRefOfTypeByPredicate.h:13
Definition IsValidVariadicFunctionArg.h:14