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

时间:2016-05-02 08:12:02

标签: c# .net winforms query-performance hard-drive

我想获得有关磁盘性能的以下信息。 enter image description here

我使用MSStorageDriver_FailurePredictThresholdsMSStorageDriver_ATAPISmartDataMSStorageDriver_FailurePredictStatus类来获取相关信息但未获得正确的结果。

2 个答案:

答案 0 :(得分:1)

这不是您想要的一切,但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 

答案 1 :(得分:0)

如果您正在寻找此项,请查看此Link。输出的一个例子是:

 ###############################################################

 Current Directory Path: D:\WinDDK\32bit\drivespeed
 Total MB  230000, Free MB  103752, Used MB  126248

 Windows Storage Speed Test 32-Bit Version 1.2, Thu Mar 01 22:31:08 2012

                Copyright (C) Roy Longbottom 2011

     8 MB File         1          2          3          4          5
 Writing MB/sec      56.68     105.37      61.95      72.48      75.33
 Reading MB/sec      80.65     108.15      81.10      81.42      82.25

    16 MB File         1          2          3          4          5
 Writing MB/sec      81.53      94.61      81.41      88.06      71.39
 Reading MB/sec      88.25      72.75      93.53      93.51      92.70

    32 MB File         1          2          3          4          5
 Writing MB/sec      90.35      83.60      72.52      80.24      72.71
 Reading MB/sec      87.00      87.67      78.39      80.24      78.62

 ---------------------------------------------------------------------
 8 MB Cached File      1          2          3          4          5
 Writing MB/sec     703.27     628.08    1050.99    1617.29    1609.70
 Reading MB/sec    1930.60    2045.13    2054.49    2135.91    2390.08

 ---------------------------------------------------------------------
 Bus Speed Block KB     64        128        256        512       1024
 Reading MB/sec     174.36     189.07     221.83     247.82     261.21

 ---------------------------------------------------------------------
 1 KB Blocks File MB >    2      4      8     16     32     64    128
 Random Read  msecs    0.14   0.14   0.15   0.17   3.24   6.96   8.90
 Random Write msecs    0.53   0.66   1.03   1.38   1.74   1.83   2.42

 ---------------------------------------------------------------------
 500 Files   Write             Read             Delete
 File KB     MB/sec  ms/File   MB/sec  ms/File  Seconds
       2       0.32     6.44     0.95     2.17    0.123
       4       6.49     0.63    12.21     0.34    0.113
       8      11.54     0.71    15.17     0.54    0.121
      16      22.04     0.74    41.78     0.39    0.116
      32      32.92     1.00    26.31     1.25    0.074
      64      68.72     0.95    51.88     1.26    0.132

              End of test Thu Mar 01 22:32:11 2012