问题描述
我试图创建一个性能计数器,可以监视应用程序的性能时,其中一个是谷歌浏览器。然而,我注意到,演出时间,我得到的铬是不自然低 - 我看任务管理器下实现我的问题,Chrome浏览器在完全相同的名称运行多个进程,但每个进程都有一个不同的工作组大小因此(我会相信)不同的处理器时间。我试着这样做:
I'm trying to create a performance counter that can monitor the performance time of applications, one of which is Google Chrome. However, I notice that the performance time I get for chrome is unnaturally low - I look under the task-manager to realize my problem that chrome has more than one process running under the exact same name, but each process has a different working set size and thus(what I would believe) different processor times. I tried doing this:
// get all processes running under the same name, and make a performance counter
// for each one.
Process[] toImport = Process.GetProcessesByName("chrome");
instances = new PerformanceCounter[toImport.Length];
for (int i = 0; i < instances.Length; i++)
{
PerformanceCounter toPopulate = new PerformanceCounter
("Process", "% Processor Time",
toImport[i].ProcessName,
true);
//Console.WriteLine(toImport[i].ProcessName + "#" + i);
instances[i] = toPopulate;
}
但是,这似乎并没有在所有的工作 - 我只是监控相同在处理好几倍。谁能告诉我的方式来监测独立进程具有相同的名称?
But that doesn't seem to work at all - I just monitor the same process several times over. Can anyone tell me of a way to monitor separate processes with the same name?
推荐答案
打开性能监视器
和外观。您需要使用像铬#2
或可能的话, chrome_2
。
Open perfmon
and look. You need to use names like chrome#2
or, possibly, chrome_2
.
这篇关于如何使用性能计数器在C#中监控4个进程具有相同的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!