0
有什麼方法可以查看應用程序註冊了所有性能計數器?如何查看/調試System.Diagnostics計數器?
有什麼方法可以查看應用程序註冊了所有性能計數器?如何查看/調試System.Diagnostics計數器?
是的,你可以檢查PerformanceCounterCategory
類的GetCounter()
方法。你會拿一個PerformanceCounter[]
和一些關於每個櫃檯的信息。
PerformanceCounterCategory pcc = new PerformanceCounterCategory();
// Retrieves the list of performance object instances that are associated with this category.
foreach (string instanceName in pcc.GetInstanceNames())
// Retrieves a list of the counters in a performance counter category that contains exactly one instance.
foreach (PerformanceCounter counter in pcc.GetCounters())
{
// now you have the counter object that represents a PerformanceCounter to get some information about the performance counter
Console.WriteLine("Category: " + counter.Category);
Console.WriteLine("Instance Name: " + counter.InstanceName);
Console.WriteLine("Machine Name: " + counter.MachineName);
Console.WriteLine("Counter Name: " + counter.CounterName);
Console.WriteLine("Next Value: " + counter.NextValue());
}
相關http://stackoverflow.com/questions/1304949/list-all-performance-counters-for-a-category –