【问题标题】:How can we get Disk Performance info in C#我们如何在 C# 中获取磁盘性能信息
【发布时间】:2016-08-26 22:48:33
【问题描述】:

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

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

【问题讨论】:

  • 首先,贴出你正在使用的代码。并更具体地说明“没有得到正确的结果”
  • 另外,确切地您对什么信息感兴趣?您想要此处显示的所有数据(这可能会使问题过于宽泛),还是只显示其中的一部分?
  • 我想要显示的所有数据位,但是如果我得到任何一位结果之后我可以获得更多位...
  • 你可以看看here
  • Thankx 但这些不是图像中显示的结果,我尝试了“Win32_DiskDrive”的所有字段但没有磁盘性能信息,它返回磁盘信息。

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


【解决方案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 

【讨论】:

    【解决方案2】:

    如果您正在寻找此内容,请查看此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
    

    【讨论】:

    • 我认为我们可以将这些值存储在文本文件中,因为它可以在 cmd 中执行。之后我们可以使用c#中的文件处理来获取这些信息。
    猜你喜欢
    • 2011-12-08
    • 2019-08-06
    • 2020-03-01
    • 1970-01-01
    • 2010-09-29
    • 1970-01-01
    • 2011-05-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多