I’m trying to figure out how to get the CPU usage for a particular process but can only find information relating to overall CPU usage.
Does anyone know how to extract the current CPU usage in percentage terms for a specific application?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Performance Counters – Process – % Processor Time.
Little sample code to give you the idea:
Notes for finding the instance based on Process ID:
I do not know of any better way, and hopefully somebody does. If not, here is one way you can find the right instance name for your process given the Process ID and process name.
There is another Performance Counter (PC) called
"ID Process"under the"Process"family. It returns the PID for the instance. So, if you already know the name (i.e. “chrome” or “myapp”), you can then test each instance until you find the match for the PID.The naming is simple for each instance: “myapp” “myapp#1” “myapp#2” … etc.
Once the PC’s value equals the PID, you found the right
appName. You can then use thatappNamefor the other counters.