System.Diagnostics.PerformanceCounter测量每个模块的CPU利用率

时间:2013-02-19 13:59:51

标签: c# .net performance module system.diagnostics

是否可以跟踪进程中每个模块的CPU利用率?在下面的代码中,可以确定myProcess.Modules中每个模块的CPU和内存消耗吗?

Process[] currentProcesses = Process.GetProcesses();
Process myProcess = currentProcesses[0];

using (PerformanceCounter pcProcess = new PerformanceCounter(
    "Process", 
    "% Processor    Time", 
    targetProcess.ProcessName))
using (PerformanceCounter memProcess = new PerformanceCounter(
    "Process",   
    "Working Set - Private",
    targetProcess.ProcessName))
{
    pcProcess.NextValue();
}

0 个答案:

没有答案