UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
DiskUtilizationTracker.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#ifndef TRACK_DISK_UTILIZATION
6#define TRACK_DISK_UTILIZATION 0
7#endif
8
9#include "CoreTypes.h"
10
11#if TRACK_DISK_UTILIZATION
12#include "HAL/PlatformMisc.h"
13#include "HAL/ThreadSafeBool.h"
15
17
18#ifndef SPEW_DISK_UTILIZATION
19#define SPEW_DISK_UTILIZATION 0
20#endif // SPEW_DISK_UTILIZATION
21
23{
24 struct UtilizationStats
25 {
27 TotalReads(0),
28 TotalSeeks(0),
29 TotalBytesRead(0),
31 TotalIOTime(0.0),
32 TotalIdleTime(0.0)
33 {}
34
35 double GetOverallThroughputBS() const
36 {
37 return (TotalIOTime + TotalIdleTime) > 0.0 ? double(TotalBytesRead) / (TotalIOTime + TotalIdleTime) : 0.0;
38 }
39
40 double GetOverallThroughputMBS() const
41 {
42 return GetOverallThroughputBS() / (1024.0 * 1024.0);
43 }
44
45 double GetReadThrougputBS() const
46 {
47 return TotalIOTime > 0.0 ? double(TotalBytesRead) / TotalIOTime : 0.0;
48 }
49
50 double GetReadThrougputMBS() const
51 {
52 return GetReadThrougputBS() / (1024.0 * 1024.0);
53 }
54
55 double GetTotalIdleTimeInSeconds() const
56 {
57 return TotalIdleTime;
58 }
59
60 double GetTotalIOTimeInSeconds() const
61 {
62 return TotalIOTime;
63 }
64
65 double GetPercentTimeIdle() const
66 {
67 double TotalTime = TotalIOTime + TotalIdleTime;
68
69 return TotalTime > 0.0 ? (100.0f * TotalIdleTime) / TotalTime : 0.0;
70 }
71
72 void Reset()
73 {
74 TotalReads = 0;
75 TotalSeeks = 0;
76 TotalBytesRead = 0;
78 TotalIOTime = 0.0;
79 TotalIdleTime = 0.0;
80 }
81
82 void Dump() const;
83
86
87 uint64 TotalBytesRead;
89
90 double TotalIOTime;
91 double TotalIdleTime;
92 };
93
96
97 FCriticalSection CriticalSection;
98
101
104
106
110 InFlightBytes(0),
112 {
113 }
114
116 void FinishRead();
117
119 {
120 return InFlightReads;
121 }
122
123 const struct UtilizationStats& GetLongTermStats() const
124 {
125 return LongTermStats;
126 }
127
128 const struct UtilizationStats& GetShortTermStats() const
129 {
130 return ShortTermStats;
131 }
132
134 {
136 }
137
138private:
139 static float GetThrottleRateMBS();
140 static constexpr float PrintFrequencySeconds = 0.5f;
141
142 void MaybePrint();
143};
144
146
148{
150 {
152 }
153
155 {
156 GDiskUtilizationTracker.FinishRead();
157 }
158};
159
160#else
161
168
169#endif // TRACK_DISK_UTILIZATION
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
UE::FPlatformRecursiveMutex FCriticalSection
Definition CriticalSection.h:53
#define CSV_DECLARE_CATEGORY_EXTERN(CategoryName)
Definition CsvProfiler.h:79
uint32 Size
Definition VulkanMemory.cpp:4034
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition ThreadSafeBool.h:17
Definition DiskUtilizationTracker.h:163
FScopedDiskUtilizationTracker(uint64 Size, uint64 SeekDistance)
Definition DiskUtilizationTracker.h:164