UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ThreadIdleStats.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "CoreTypes.h"
5#include "HAL/PlatformTime.h"
8
9namespace UE::Stats
10{
11 class FThreadIdleStats;
12}
13
15
16namespace UE::Stats
17{
18
22 class FThreadIdleStats : public TThreadSingleton<FThreadIdleStats>
23 {
25
27 : Waits(0)
30 , bInIdleScope(false)
31 {}
32
33 public:
34
37
40
43
48
53
65
66 bool IsCriticalPath() const
67 {
68 return IsCriticalPathCounter > 0;
69 }
70
71 void Reset()
72 {
73 Waits = 0;
76 }
77
78
79
81 {
82#if defined(DISABLE_THREAD_IDLE_STATS) && DISABLE_THREAD_IDLE_STATS
83 FScopeIdle(bool bInIgnore = false)
84 {}
85#else
88
90 const bool bIgnore;
91
92#if CPUPROFILERTRACE_ENABLED
93 FCpuProfilerTrace::FEventScope TraceEventScope;
94#endif
95
96 CORE_API FScopeIdle(bool bInIgnore = false);
97
99 {
100 if (!bIgnore)
101 {
104 IdleStats.Waits += CyclesElapsed;
105
106 if (IdleStats.IsCriticalPath())
107 {
108 IdleStats.WaitsCriticalPath += CyclesElapsed;
109 }
110
111 IdleStats.bInIdleScope = false;
112 }
113 }
114#endif
115 };
116 };
117} // namespace UE::Stats
118
119UE_DEPRECATED(5.6, "Use UE::Stats::FThreadIdleStats instead.")
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE::Stats::FThreadIdleStats FThreadIdleStats
Definition ThreadIdleStats.h:120
#define UE_DECLARE_THREAD_SINGLETON_TLS(Type, Api)
Definition ThreadSingleton.h:35
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition ThreadSingleton.h:44
static FORCEINLINE FThreadIdleStats & Get()
Definition ThreadSingleton.h:101
Definition ThreadIdleStats.h:23
static void EndCriticalPath()
Definition ThreadIdleStats.h:49
void Reset()
Definition ThreadIdleStats.h:71
uint32 Waits
Definition ThreadIdleStats.h:36
bool bInIdleScope
Definition ThreadIdleStats.h:42
int IsCriticalPathCounter
Definition ThreadIdleStats.h:41
static void BeginCriticalPath()
Definition ThreadIdleStats.h:44
bool IsCriticalPath() const
Definition ThreadIdleStats.h:66
uint32 WaitsCriticalPath
Definition ThreadIdleStats.h:39
Definition StatsCommand.cpp:2274
Definition AdvancedWidgetsModule.cpp:13
static uint32 Cycles()
Definition AndroidPlatformTime.h:27
Definition ThreadIdleStats.h:81
const bool bIgnore
Definition ThreadIdleStats.h:90
~FScopeIdle()
Definition ThreadIdleStats.h:98
const uint32 Start
Definition ThreadIdleStats.h:87
~FScopeNonCriticalPath()
Definition ThreadIdleStats.h:60
FScopeNonCriticalPath()
Definition ThreadIdleStats.h:56