views:

129

answers:

1

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?

+1  A: 

Open perfmon and look. You need to use names like chrome#2 or, possibly, chrome_2.

Anton Tykhyy
Thank you! I had no idea something as useful as the perfmon existed.
Waffles