如何获得Readyboost缓存大小?

时间:2016-04-22 07:34:51

标签: c# caching

我写了一个C#控制台应用程序,它从性能计数器读取Readyboost数据。

我的问题是Readyboost报告的缓存大小不正确。例如,当readyboost pendrive未连接到计算机时,它会报告“总高速缓存大小字节:1.157366E + 08”。

这是我的代码和应用程​​序的输出。我做错了什么?

static void Main(string[] args)
{
    System.Threading.Thread.CurrentThread.CurrentCulture = 
      System.Globalization.CultureInfo.CreateSpecificCulture("en-US");

    System.Diagnostics.PerformanceCounterCategory pc;

    try
    {
        pc = new System.Diagnostics.PerformanceCounterCategory("ReadyBoost Cache");
        foreach (PerformanceCounter counter in pc.GetCounters())
        {
            Console.WriteLine("{0}: {1}", counter.CounterName, counter.NextValue());
        }
    }
    catch (Exception ex)
    {
        Console.WriteLine("Error: {0}", ex);
    }

    Console.ReadKey();
}

输出:

Bytes cached: 3.737436E+08
Cache space used: 1.06779E+08
Compression Ratio: 0
Total cache size bytes: 1.157366E+08
Cache reads/sec: 0
Cache read bytes/sec: 0
Skipped reads/sec: 0
Skipped read bytes/sec: 0
Total reads/sec: 0
Total read bytes/sec: 0

0 个答案:

没有答案