[英]performance Counter for disk read / write time
In my application, I am gathering data regarding the performance of system, where I need to find 在我的应用程序中,我正在收集有关系统性能的数据,我需要找到它
using below function; 使用以下功能;
private void CollectnPopulatePerfCounters()
{
try
{
foreach (var pc in System.Diagnostics.PerformanceCounterCategory.GetCategories())
{
if (pc.CategoryName == "LogicalDisk" || pc.CategoryName == "Paging File" || pc.CategoryName == "ProcessorPerformance")
{
try
{
foreach (var insta in pc.GetInstanceNames())
{
try
{
foreach (PerformanceCounter cntr in pc.GetCounters(insta))
{
using (System.IO.StreamWriter sw = new System.IO.StreamWriter("C:\\amit.txt", true))
{
sw.WriteLine("--------------------------------------------------------------------");
sw.WriteLine("Category Name : " + pc.CategoryName);
sw.WriteLine("Counter Name : " + cntr.CounterName);
sw.WriteLine("Explain Text : " + cntr.CounterHelp);
sw.WriteLine("Instance Name: " + cntr.InstanceName);
sw.WriteLine("Value : " + Convert.ToString(cntr.RawValue)); //TODO:
sw.WriteLine("Counter Type : " + cntr.CounterType);
sw.WriteLine("--------------------------------------------------------------------");
}
}
}
catch (Exception) { }
}
}
catch (Exception) { }
}
}
}
catch (Exception) { }
}
When the code is executed the data is generated. 执行代码时,将生成数据。 While observing I found that the value against the above mentioned list [ie % free space, % disk time etc.] is not in correct form.
在观察时我发现上述列表的值[即%可用空间,%磁盘时间等]的形式不正确。
On my machine the value for 在我的机器上的值
actually the value should be in the percent form [ ie within the range of 0 to 100 % ] 实际上该值应该是百分比形式[ 即在0到100%的范围内 ]
Is there any way to get the exact value for all these except [% free Space for which I have calculated]. 有没有办法获得所有这些的确切值,除了[我已计算的%自由空间]。
Or 要么
Does anyone know how to calculate for rest of all headers. 有谁知道如何计算所有标题的其余部分。
Use following 使用以下
sw.WriteLine("Value : " + Convert.ToString(Math.Round(cntr.NextValue(),2)) + "%");
More info at: 更多信息:
Why the cpu performance counter kept reporting 0% cpu usage? 为什么cpu性能计数器保持报告0%cpu使用率?
All the best! 祝一切顺利!
Don't forget to vote :-D 别忘了投票:-D
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.