我们如何在C#中获取磁盘性能信息

我想获得有关磁盘性能的以下信息.

《我们如何在C#中获取磁盘性能信息》

我使用了MSStorageDriver_FailurePredictThresholds,MSStorageDriver_ATAPISmartData,MSStorageDriver_FailurePredictStatus类来获取相关信息但没有得到正确的结果.

最佳答案 这不是您想要的一切,但
Win32_PerfFormattedData_PerfDisk_PhysicalDisk WMI类为您提供当前的读/写/传输速率和活动时间.它也提供了一些平均值,但我不确定它们是如何计算的(AvgDiskBytesPerWrite为0似乎很奇怪)

// NOTE: Use ManagementObjectSearcher to find the path your interested in
var path = "Win32_PerfFormattedData_PerfDisk_PhysicalDisk.Name='0 C:'";
var wmiObj = new ManagementObject(path);
wmiObj.Properties.Cast<PropertyData>().ToDictionary(p => p.Name, p => p.Value).Dump();

/* OUTPUT */
AvgDiskBytesPerRead     63167 
AvgDiskBytesPerTransfer 63167 
AvgDiskBytesPerWrite    0 
AvgDiskQueueLength      0 
AvgDiskReadQueueLength  0 
AvgDisksecPerRead       0 
AvgDisksecPerTransfer   0 
AvgDisksecPerWrite      0 
AvgDiskWriteQueueLength 0 
Caption                 null 
CurrentDiskQueueLength  0 
Description             null 
DiskBytesPersec         20991616 
DiskReadBytesPersec     20991616 
DiskReadsPersec         332 
DiskTransfersPersec     332 
DiskWriteBytesPersec    0 
DiskWritesPersec        0 
Frequency_Object        null 
Frequency_PerfTime      null 
Frequency_Sys100NS      null 
Name                    0 C: 
PercentDiskReadTime     80 
PercentDiskTime         80 
PercentDiskWriteTime    0 
PercentIdleTime         32 
SplitIOPerSec           0 
Timestamp_Object        null 
Timestamp_PerfTime      null 
Timestamp_Sys100NS      null 
点赞