UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ChartCreation.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
8#pragma once
9
10#include "CoreMinimal.h"
12#include "Scalability.h"
14
16
17// What kind of hitch was detected (if any)
19{
20 // We didn't hitch
21 NoHitch,
22
23 // We hitched but couldn't isolate which unit caused it
25
26 // Hitched and it was likely caused by the game thread
28
29 // Hitched and it was likely caused by the render thread
31
32 // Hitched and it was likely caused by the RHI thread
34
35 // Hitched and it was likely caused by the GPU
36 GPU
37};
38
39
41// IPerformanceDataConsumer
42
43// This is an interface for any consumer of per-frame performance data
44// such as FPS charts, PerfCounters, analytics, etc...
45
47{
48public:
50 {
51 // Estimate of how long the last frame was (this is either TrueDeltaSeconds or TrueDeltaSeconds - IdleSeconds, depending on the cvar t.FPSChart.ExcludeIdleTime)
53
54 // Time elapsed since the last time the performance tracking system ran
56
57 // How long did we burn idling until this frame (FApp::GetIdleTime) (e.g., when running faster than a frame rate target on a dedicated server)
59
60 // How long did we burn idling beyond what we requested this frame (FApp::GetIdleTimeOvershoot). WaitTime we requested for the frame = IdleSeconds - IdleOvershootSeconds.
62
63 // Duration of each of the major functional units (GPU time is frequently inferred rather than actual)
72
75
82
85
86 // Should this frame be considered for histogram generation (controlled by t.FPSChart.MaxFrameDeltaSecsBeforeDiscarding)
88
89 // Was this frame bound in one of the major functional units (only set if bBinThisFrame is true and the frame was longer than FEnginePerformanceTargets::GetTargetFrameTimeThresholdMS)
94
95 // Did we hitch?
97
98 // If a hitch, how was it bound
99 //@TODO: This uses different logic to the three bools above but probably shouldn't (though it also ignores the MaxFrameDeltaSecsBeforeDiscarding)
100
125 };
126
127 virtual void StartCharting()=0;
128 virtual void ProcessFrame(const FFrameData& FrameData)=0;
129 virtual void StopCharting()=0;
131};
132
134// FPerformanceTrackingChart
135
141{
142public:
143 // The mode being tracked by this chart
144 FString ChartLabel;
145
146 // Frame time histogram (in seconds)
148
149 // Hitch time histogram (in seconds)
151
152 // Hitch time histogram (in seconds)
154
155 // Track size of the async loader package queue (I/O)
157
163
169
175
180
183
189
194
202
209
214
217
220
225
228
231
234
236
237 // memory stats
246
247public:
251
252 // Discard all accumulated data
254
256
257 double GetTotalTime() const
258 {
260 }
261
263 {
265 }
266
267 double GetAverageFramerate() const
268 {
269 return GetNumFrames() / GetTotalTime();
270 }
271
273 {
275 }
276
282
284 {
285 const double TotalTime = GetTotalTime();
287 return (TotalTime > 0.0) ? ((TotalHitchTime * 100.0) / TotalTime) : 0.0;
288 }
289
291 {
292 const int64 TotalTargetFrames = static_cast<int64>(TargetFPS * GetTotalTime());
293 const int64 MissedFrames = FMath::Max<int64>(TotalTargetFrames - GetNumFrames(), 0);
294 return ((MissedFrames * 100.0) / (double)TotalTargetFrames);
295 }
296
298 {
299 const double TotalTime = GetTotalTime();
301
302 return (TotalTime > 0.0) ? (TotalHitchCount / (TotalTime / 60.0f)) : 0.0;
303 }
304
306 {
308 }
309
311
312 void ChangeLabel(const FString& NewLabel)
313 {
315 }
316
317 ENGINE_API void DumpFPSChart(const FString& InMapName);
318
319 // Dumps the FPS chart information to an analytic event param array.
320 ENGINE_API void DumpChartToAnalyticsParams(const FString& InMapName, TArray<struct FAnalyticsEventAttribute>& InParamArray, bool bIncludeClientHWInfo, bool bIncludeHistograms = true) const;
321
322
323 // Dumps the FPS chart information to the log.
325
326#if ALLOW_DEBUG_FILES
327 // Dumps the FPS chart information to HTML.
329
330 // Dumps the FPS chart information to the special stats log file.
332#endif
333
334 // IPerformanceDataConsumer interface
335 ENGINE_API virtual void StartCharting() override;
336 ENGINE_API virtual void ProcessFrame(const FFrameData& FrameData) override;
337 ENGINE_API virtual void StopCharting() override;
338 // End of IPerformanceDataConsumer interface
339
342};
343
345// FFineGrainedPerformanceTracker
346
347#if ALLOW_DEBUG_FILES
348
349// Fine-grained tracking (records the frame time of each frame rather than just a histogram)
351{
352public:
354
356 ENGINE_API void Presize(int32 NumFrames);
357
362
371
372 // IPerformanceDataConsumer interface
373 ENGINE_API virtual void StartCharting() override;
374 ENGINE_API virtual void ProcessFrame(const FFrameData& FrameData) override;
375 ENGINE_API virtual void StopCharting() override;
376 // End of IPerformanceDataConsumer interface
377
378public:
382 TArray<float> GPUFrameTimes;
383 TArray<float> FrameTimes;
386
388 const FDateTime CaptureStartTime;
389
392};
393
394#endif
395
397// FPerformanceTrackingSystem
398
399// Overall state of the built-in performance tracking
401{
402public:
404
408
416 static ENGINE_API FString CreateFileNameForChart(const FString& ChartType, const FString& InMapName, const FString& FileExtension);
417
419 static ENGINE_API FString CreateOutputDirectory(const FDateTime& CaptureStartTime);
420
421 // Should we subtract off idle time spent waiting (due to running above target framerate) before thresholding into bins?
422 // (controlled by t.FPSChart.ExcludeIdleTime)
424
425private:
427 double FPSChartStartTime;
428
430 double FPSChartStopTime;
431
433 double LastTimeChartCreationTicked;
434
436 float LastDeltaSeconds;
437
439 double LastHitchTime;
440};
441
443
444// Prints the FPS chart summary to an endpoint
446{
447protected:
449
450public:
454 ENGINE_API void DumpChart(double InWallClockTimeFromStartOfCharting, FString InMapName, FString InDeviceProfileName = FString(TEXT("Unknown")));
455
460
462
463protected:
464 double WallClockTimeFromStartOfCharting; // This can be much larger than TotalTime if the chart was paused or long frames were omitted
465 FString MapName;
467
471
476
478
482
485 FString WindowMode;
486
487 FString OSMajor;
488 FString OSMinor;
489
490 FString CPUVendor;
491 FString CPUBrand;
492
493 // The primary GPU for the desktop (may not be the one we ended up using, e.g., in an optimus laptop)
495
496 // The actual GPU adapter we initialized
498
499protected:
500 virtual void PrintToEndpoint(const FString& Text) = 0;
501
502 ENGINE_API virtual void FillOutMemberStats();
503 ENGINE_API virtual void HandleHitchBucket(const FHistogram& HitchHistogram, int32 BucketIndex);
507 ENGINE_API virtual void HandleBasicStats();
508};
EFrameHitchType
Definition ChartCreation.h:19
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
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
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition ChartCreation.h:141
int32 MinDrawnPrimitives
Definition ChartCreation.h:212
double TotalFramesBoundTime_GameThread
Definition ChartCreation.h:165
FDateTime CaptureStartTime
Definition ChartCreation.h:216
int32 MinPlayerTicks
Definition ChartCreation.h:200
ENGINE_API FPerformanceTrackingChart()
Definition ChartCreation.cpp:569
int32 TotalFlushAsyncLoadingCalls
Definition ChartCreation.h:178
double GetAvgHitchFrameLength() const
Definition ChartCreation.h:305
double MaxFlushAsyncLoadingTime
Definition ChartCreation.h:179
int64 TotalDrawnPrimitives
Definition ChartCreation.h:213
double TotalFramesBoundTime_RenderThread
Definition ChartCreation.h:166
int StopBatteryLevel
Definition ChartCreation.h:230
uint64 TotalPhysicalMemoryUsed
Definition ChartCreation.h:244
int64 GetNumHitches() const
Definition ChartCreation.h:272
uint32 NumFramesBound_RHIThread
Definition ChartCreation.h:161
ENGINE_API void AccumulateWith(const FPerformanceTrackingChart &Chart)
Definition ChartCreation.cpp:662
ENGINE_API void DumpChartToAnalyticsParams(const FString &InMapName, TArray< struct FAnalyticsEventAttribute > &InParamArray, bool bIncludeClientHWInfo, bool bIncludeHistograms=true) const
Definition ChartCreation.cpp:948
int32 TotalGPUBoundHitchCount
Definition ChartCreation.h:188
uint32 NumFramesBound_GPU
Definition ChartCreation.h:162
int32 TotalVehicleTicks
Definition ChartCreation.h:208
double GetPercentHitchTime(bool bSubtractHitchThreshold=true) const
Definition ChartCreation.h:283
int32 TotalGameThreadBoundHitchCount
Definition ChartCreation.h:185
uint32 NumFramesBound_GameThread
Definition ChartCreation.h:159
double TotalFramesBoundTime_RHIThread
Definition ChartCreation.h:167
double GetTotalTime() const
Definition ChartCreation.h:257
float StartTemperatureLevel
Definition ChartCreation.h:226
virtual ENGINE_API void StartCharting() override
Definition ChartCreation.cpp:729
int32 TotalRenderThreadBoundHitchCount
Definition ChartCreation.h:186
bool bIsChartingPaused
Definition ChartCreation.h:235
virtual ENGINE_API void ProcessFrame(const FFrameData &FrameData) override
Definition ChartCreation.cpp:753
ENGINE_API void DumpChartsToOutputLog(double WallClockElapsed, const TArray< const FPerformanceTrackingChart * > &Charts, const FString &InMapName)
Definition ChartCreation.cpp:909
virtual ENGINE_API void StopCharting() override
Definition ChartCreation.cpp:737
int32 TotalPlayerTicks
Definition ChartCreation.h:201
double AccumulatedChartTime
Definition ChartCreation.h:219
void ChangeLabel(const FString &NewLabel)
Definition ChartCreation.h:312
int32 TotalRHIThreadBoundHitchCount
Definition ChartCreation.h:187
ENGINE_API void PauseCharting()
Definition ChartCreation.cpp:743
uint64 TotalVirtualMemoryUsed
Definition ChartCreation.h:245
ENGINE_API void ResumeCharting()
Definition ChartCreation.cpp:748
ENGINE_API double GetTotalHitchFrameTime(bool bSubtractHitchThreshold=true) const
Definition ChartCreation.cpp:716
int64 GetNumFrames() const
Definition ChartCreation.h:262
FHistogram AsyncPackageQueueHistogram
Definition ChartCreation.h:156
uint32 NumFramesAtCriticalMemoryPressure
Definition ChartCreation.h:238
int32 MinDrawCalls
Definition ChartCreation.h:192
double GetAvgHitchesPerMinute() const
Definition ChartCreation.h:297
uint64 MaxPhysicalMemory
Definition ChartCreation.h:239
uint64 MinPhysicalMemory
Definition ChartCreation.h:241
double TotalFrameTime_RenderThread
Definition ChartCreation.h:172
double TotalFramesBoundTime_GPU
Definition ChartCreation.h:168
virtual ENGINE_API ~FPerformanceTrackingChart()
Definition ChartCreation.cpp:574
double TimeDisregarded
Definition ChartCreation.h:222
uint64 MinAvailablePhysicalMemory
Definition ChartCreation.h:243
double TotalFrameTime_GameThread
Definition ChartCreation.h:171
FHistogram HitchTimeHistogram
Definition ChartCreation.h:150
FHistogram FrametimeHistogram
Definition ChartCreation.h:147
uint64 MaxVirtualMemory
Definition ChartCreation.h:240
int32 MaxDrawCalls
Definition ChartCreation.h:191
int StartBatteryLevel
Definition ChartCreation.h:229
uint32 NumFramesBound_RenderThread
Definition ChartCreation.h:160
FHistogram DynamicResHistogram
Definition ChartCreation.h:153
int32 MaxVehicleTicks
Definition ChartCreation.h:207
int32 MaxDrawnPrimitives
Definition ChartCreation.h:211
double TotalFrameTime_RHIThread
Definition ChartCreation.h:173
uint64 MinVirtualMemory
Definition ChartCreation.h:242
double TotalFlushAsyncLoadingTime
Definition ChartCreation.h:177
int32 MaxPlayerTicks
Definition ChartCreation.h:199
int32 TotalDrawCalls
Definition ChartCreation.h:193
int FramesDisregarded
Definition ChartCreation.h:224
ENGINE_API double GetPercentFramesIOBusy(int32 StartingBin=0) const
Definition ChartCreation.cpp:860
double TotalFrameTime_GPU
Definition ChartCreation.h:174
FString DeviceProfileName
Definition ChartCreation.h:233
uint32 TotalSyncLoadCount
Definition ChartCreation.h:182
double GetAverageFramerate() const
Definition ChartCreation.h:267
ENGINE_API void DumpFPSChart(const FString &InMapName)
Definition ChartCreation.cpp:884
double GetPercentMissedVSync(int32 TargetFPS) const
Definition ChartCreation.h:290
FString ChartLabel
Definition ChartCreation.h:144
float StopTemperatureLevel
Definition ChartCreation.h:227
Definition ChartCreation.h:47
virtual void StartCharting()=0
virtual void StopCharting()=0
virtual ~IPerformanceDataConsumer()
Definition ChartCreation.h:130
virtual void ProcessFrame(const FFrameData &FrameData)=0
Definition Array.h:670
@ false
Definition radaudio_common.h:23
Definition DateTime.h:76
Definition ChartCreation.h:446
double AvgFlushAsyncLoadingTimeInMS
Definition ChartCreation.h:475
virtual ENGINE_API void HandleBasicStats()
Definition ChartCreation.cpp:156
FString CPUVendor
Definition ChartCreation.h:490
double WallClockTimeFromStartOfCharting
Definition ChartCreation.h:464
FString DeviceProfileName
Definition ChartCreation.h:466
float BoundGameThreadPct
Definition ChartCreation.h:479
float AvgGPUFrameTime
Definition ChartCreation.h:468
virtual void PrintToEndpoint(const FString &Text)=0
FString OSMajor
Definition ChartCreation.h:487
const FPerformanceTrackingChart & Chart
Definition ChartCreation.h:448
float BoundGPUPct
Definition ChartCreation.h:481
int32 TotalFlushAsyncLoadingCalls
Definition ChartCreation.h:473
FDumpFPSChartToEndpoint(const FPerformanceTrackingChart &InChart)
Definition ChartCreation.h:456
virtual ~FDumpFPSChartToEndpoint()
Definition ChartCreation.h:461
Scalability::FQualityLevels ScalabilityQuality
Definition ChartCreation.h:483
FString OSMinor
Definition ChartCreation.h:488
FString DesktopGPUBrand
Definition ChartCreation.h:494
virtual ENGINE_API void HandleHitchBucket(const FHistogram &HitchHistogram, int32 BucketIndex)
Definition ChartCreation.cpp:109
FString ActualGPUBrand
Definition ChartCreation.h:497
virtual ENGINE_API void FillOutMemberStats()
Definition ChartCreation.cpp:88
FString WindowMode
Definition ChartCreation.h:485
float AvgGameThreadFrameTime
Definition ChartCreation.h:470
virtual ENGINE_API void HandleDynamicResThreshold(int32 TargetScreenPercentage, float PctTimeAbove)
Definition ChartCreation.cpp:150
virtual ENGINE_API void HandleFPSThreshold(int32 TargetFPS, float PctMissedFrames)
Definition ChartCreation.cpp:145
virtual ENGINE_API void HandleHitchSummary(int32 TotalHitchCount, double TotalTimeSpentInHitchBuckets)
Definition ChartCreation.cpp:127
double TotalFlushAsyncLoadingTimeInMS
Definition ChartCreation.h:472
FIntPoint GameResolution
Definition ChartCreation.h:484
FString CPUBrand
Definition ChartCreation.h:491
float AvgRenderThreadFrameTime
Definition ChartCreation.h:469
ENGINE_API void DumpChart(double InWallClockTimeFromStartOfCharting, FString InMapName, FString InDeviceProfileName=FString(TEXT("Unknown")))
Definition ChartCreation.cpp:212
float BoundRenderThreadPct
Definition ChartCreation.h:480
double MaxFlushAsyncLoadingTimeInMS
Definition ChartCreation.h:474
int32 TotalSyncLoadCount
Definition ChartCreation.h:477
FString MapName
Definition ChartCreation.h:465
Definition Histogram.h:34
double GetSumOfAllMeasures() const
Definition Histogram.h:125
double GetAverageOfAllMeasures() const
Definition Histogram.h:131
int64 GetNumMeasurements() const
Definition Histogram.h:119
Definition ChartCreation.h:401
static ENGINE_API bool ShouldExcludeIdleTimeFromCharts()
Definition ChartCreation.cpp:1222
ENGINE_API void StopCharting()
Definition ChartCreation.cpp:1426
static ENGINE_API FString CreateFileNameForChart(const FString &ChartType, const FString &InMapName, const FString &FileExtension)
Definition ChartCreation.cpp:1206
static ENGINE_API FString CreateOutputDirectory(const FDateTime &CaptureStartTime)
Definition ChartCreation.cpp:1214
ENGINE_API void StartCharting()
Definition ChartCreation.cpp:1406
ENGINE_API FPerformanceTrackingSystem()
Definition ChartCreation.cpp:1197
ENGINE_API IPerformanceDataConsumer::FFrameData AnalyzeFrame(float DeltaSeconds)
Definition ChartCreation.cpp:1227
Definition ChartCreation.h:50
double DeltaSeconds
Definition ChartCreation.h:52
int32 NumAsyncPackages
Definition ChartCreation.h:84
EFrameHitchType HitchStatus
Definition ChartCreation.h:96
uint32 SyncLoadCount
Definition ChartCreation.h:81
double IdleOvershootSeconds
Definition ChartCreation.h:61
uint32 FlushAsyncLoadingCount
Definition ChartCreation.h:79
bool bRenderThreadBound
Definition ChartCreation.h:91
double GameDriverTickFlushTimeSeconds
Definition ChartCreation.h:69
bool bGPUBound
Definition ChartCreation.h:93
double TrueDeltaSeconds
Definition ChartCreation.h:55
double FlushAsyncLoadingTime
Definition ChartCreation.h:77
double DemoDriverTickFlushTimeSeconds
Definition ChartCreation.h:71
bool bGameThreadBound
Definition ChartCreation.h:90
double DynamicResolutionScreenPercentage
Definition ChartCreation.h:74
double IdleSeconds
Definition ChartCreation.h:58
bool bBinThisFrame
Definition ChartCreation.h:87
double GameThreadTimeSeconds
Definition ChartCreation.h:64
bool bRHIThreadBound
Definition ChartCreation.h:92
double GPUTimeSeconds
Definition ChartCreation.h:67
FFrameData()
Definition ChartCreation.h:101
double RHIThreadTimeSeconds
Definition ChartCreation.h:66
double RenderThreadTimeSeconds
Definition ChartCreation.h:65
Definition Scalability.h:28
Definition IntPoint.h:25