UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
DynamicStats.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "AutoRTFM.h"
5#include "Misc/Build.h"
8
11{
23 template< typename TStatGroup >
25 {
26#if STATS
27 return CreateStatIdInternal<TStatGroup>(FName(*StatNameOrDescription), EStatDataType::ST_int64, true);
28#else
29 return TStatId();
30#endif // STATS
31 }
32
33 template< typename TStatGroup >
35 {
36#if STATS
37 return CreateStatIdInternal<TStatGroup>(FName(*StatNameOrDescription), EStatDataType::ST_int64, false, !bIsAccumulator);
38#else
39 return TStatId();
40#endif // STATS
41 }
42
43 template< typename TStatGroup >
45 {
46#if STATS
47 return CreateStatIdInternal<TStatGroup>(FName(*StatNameOrDescription), EStatDataType::ST_double, false, !bIsAccumulator);
48#else
49 return TStatId();
50#endif // STATS
51 }
52
53 template< typename TStatGroup >
55 {
56#if STATS
57 return CreateStatIdInternal<TStatGroup>(StatNameOrDescription, EStatDataType::ST_int64, IsTimer);
58#else
59 return TStatId();
60#endif // STATS
61 }
62
63 template< typename TStatGroup >
72
73 template< typename TStatGroup >
82
83#if STATS
84private: // private since this can only be declared if STATS is defined, due to EStatDataType in signature
85 template< typename TStatGroup >
86 static TStatId CreateStatIdInternal(const FName StatNameOrDescription, EStatDataType::Type Type, bool IsTimer, bool bClearEveryFrame = true)
87 {
88 return AutoRTFM::Open([&]
89 {
90 // #jira SOL-8290: can remove this `UnreachableIfClosed` once resolved.
91 AutoRTFM::UnreachableIfClosed();
92
94 });
95 }
96
97 template< typename TStatGroup >
99 {
100 FStartupMessages::Get().AddMetadata(StatNameOrDescription, nullptr,
101 TStatGroup::GetGroupName(),
102 TStatGroup::GetGroupCategory(),
103 TStatGroup::GetDescription(),
104 bClearEveryFrame, Type, IsTimer, false);
105
106 TStatId StatID = IStatGroupEnableManager::Get().GetHighPerformanceEnableForStat(StatNameOrDescription,
107 TStatGroup::GetGroupName(),
108 TStatGroup::GetGroupCategory(),
109 TStatGroup::DefaultEnable,
110 bClearEveryFrame, Type, nullptr, IsTimer, false);
111
112 return StatID;
113 }
114
115 template< typename TStatGroup >
117 {
118 return AutoRTFM::Open([&]
119 {
120 // #jira SOL-8290: can remove this `UnreachableIfClosed` once resolved.
121 AutoRTFM::UnreachableIfClosed();
122
124 });
125 }
126
127 template< typename TStatGroup >
129 {
130 FStartupMessages::Get().AddMetadata(StatNameOrDescription, *StatNameOrDescription.ToString(),
131 TStatGroup::GetGroupName(),
132 TStatGroup::GetGroupCategory(),
133 TStatGroup::GetDescription(),
134 false, EStatDataType::ST_int64, false, false, MemRegion);
135
136 TStatId StatID = IStatGroupEnableManager::Get().GetHighPerformanceEnableForStat(StatNameOrDescription,
137 TStatGroup::GetGroupName(),
138 TStatGroup::GetGroupCategory(),
139 TStatGroup::DefaultEnable,
140 false, EStatDataType::ST_int64, *StatNameOrDescription.ToString(), false, false, MemRegion);
141
142 return StatID;
143 }
144#endif // STATS
145};
#define AUTORTFM_DISABLE
Definition AutoRTFMDefines.h:116
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition NameTypes.h:617
Definition DynamicStats.h:11
static TStatId CreateStatIdDouble(const FString &StatNameOrDescription, bool bIsAccumulator=false)
Definition DynamicStats.h:44
static TStatId CreateMemoryStatId(const FName StatNameOrDescription, FPlatformMemory::EMemoryCounterRegion MemRegion=FPlatformMemory::MCR_Physical)
Definition DynamicStats.h:74
static TStatId CreateStatIdInt64(const FString &StatNameOrDescription, bool bIsAccumulator=false)
Definition DynamicStats.h:34
static TStatId CreateStatId(const FString &StatNameOrDescription)
Definition DynamicStats.h:24
static TStatId CreateMemoryStatId(const FString &StatNameOrDescription, FPlatformMemory::EMemoryCounterRegion MemRegion=FPlatformMemory::MCR_Physical)
Definition DynamicStats.h:64
static TStatId CreateStatId(const FName StatNameOrDescription, bool IsTimer=true)
Definition DynamicStats.h:54
EMemoryCounterRegion
Definition GenericPlatformMemory.h:249
@ MCR_Physical
Definition GenericPlatformMemory.h:251
Definition LightweightStats.h:416