5#ifndef TRACK_DISK_UTILIZATION
6#define TRACK_DISK_UTILIZATION 0
12#include "HAL/PlatformMisc.h"
13#include "HAL/ThreadSafeBool.h"
14#include "ProfilingDebugging/CsvProfiler.h"
18CSV_DECLARE_CATEGORY_EXTERN(DiskIO);
20#ifndef SPEW_DISK_UTILIZATION
21#define SPEW_DISK_UTILIZATION 0
24struct FDiskUtilizationTracker
26 struct UtilizationStats
37 double GetOverallThroughputBS()
const
39 return (TotalIOTime + TotalIdleTime) > 0.0 ?
double(TotalBytesRead) / (TotalIOTime + TotalIdleTime) : 0.0;
42 double GetOverallThroughputMBS()
const
44 return GetOverallThroughputBS() / (1024.0 * 1024.0);
47 double GetReadThrougputBS()
const
49 return TotalIOTime > 0.0 ?
double(TotalBytesRead) / TotalIOTime : 0.0;
52 double GetReadThrougputMBS()
const
54 return GetReadThrougputBS() / (1024.0 * 1024.0);
57 double GetTotalIdleTimeInSeconds()
const
62 double GetTotalIOTimeInSeconds()
const
67 double GetPercentTimeIdle()
const
69 double TotalTime = TotalIOTime + TotalIdleTime;
71 return TotalTime > 0.0 ? (100.0f * TotalIdleTime) / TotalTime : 0.0;
79 TotalSeekDistance = 0;
89 uint64 TotalBytesRead;
90 uint64 TotalSeekDistance;
96 UtilizationStats LongTermStats;
97 UtilizationStats ShortTermStats;
99 FCriticalSection CriticalSection;
101 uint64 IdleStartCycle;
102 uint64 ReadStartCycle;
104 uint64 InFlightBytes;
107 FThreadSafeBool bResetShortTermStats;
109 FDiskUtilizationTracker() :
117 void StartRead(uint64 InReadBytes, uint64 InSeekDistance = 0);
120 uint32 GetOutstandingRequests()
const
122 return InFlightReads;
125 const struct UtilizationStats& GetLongTermStats()
const
127 return LongTermStats;
130 const struct UtilizationStats& GetShortTermStats()
const
132 return ShortTermStats;
135 void ResetShortTermStats()
137 bResetShortTermStats =
true;
141 static float GetThrottleRateMBS();
142 static constexpr float PrintFrequencySeconds = 0.5f;
147extern FDiskUtilizationTracker GDiskUtilizationTracker;
149struct FScopedDiskUtilizationTracker
151 FScopedDiskUtilizationTracker(uint64 InReadBytes, uint64 InSeekDistance)
153 GDiskUtilizationTracker.StartRead(InReadBytes, InSeekDistance);
156 ~FScopedDiskUtilizationTracker()
158 GDiskUtilizationTracker.FinishRead();
#define TRACK_DISK_UTILIZATION
FScopedDiskUtilizationTracker(uint64 Size, uint64 SeekDistance)