How can I monitor the CPU usage of one process over a period of time?

8

4

I want to know what the average CPU usage is of a particular executable on my PC over a day.

I could write a C# app to do this, but I figured this is exactly the sort of app Superuser would know about if it exists!

I'm using Windows 7 64 bit, in case it matters!

Thanks!

Josh Comley

Posted 2010-04-30T08:55:02.627

Reputation: 3 582

Answers

9

Go to the Performance Monitor. Right-click on the graph and select "Add Counters".

In the "Available counters" list, open the "Process" section by clicking on the down arrow next to it. Select "% Processor Time" (and any other counter you want).

In the "Instances of selected object" list, select the process you want to track. Then click on "Add >>". Click on OK once you have what you need.

This will give a graph of the CPU usage for the chosen application.

Snark

Posted 2010-04-30T08:55:02.627

Reputation: 30 147

4

Another application that any Superuser should use is Process Explorer.

See in Mark Russinovich's technical blog the article The Case of the System Process CPU Spikes, where he tracked down a CPU spike caused by his network driver.

harrymc

Posted 2010-04-30T08:55:02.627

Reputation: 306 093

I use Process Explorer, but am not sure how to record CPU usage with it! – Josh Comley – 2010-04-30T11:14:28.160

@joshcomley: read the above article. In short: Just double-click on the process and explore the available tabs. – harrymc – 2010-04-30T11:41:24.023

0

Here's link that may be of use to you: http://zamov.online.fr/EXHTML/CSharp/CSharp_927308.html

Otherwise, have a look through the System.Diagnostics namespace (a quick search on System.Diagnostics shows up the relevant page).

Salami

Posted 2010-04-30T08:55:02.627

Reputation: 237

0

following command gets the average of cpu and memory usage every 50 second for specific process(pid)

pidstat 50 -ru -p <pid>

output for my case(firs two lines for cpu-usage, second two lines for memory):

02:17:47 PM       PID    %usr %system  %guest    %CPU   CPU  Command
02:18:27 PM     24563    0.38    0.07    0.00    0.45     3  java

02:17:47 PM       PID  minflt/s  majflt/s     VSZ    RSS   %MEM  Command
02:18:27 PM     24563     11.68      0.00 13047972 2123268   6.52  java

Celik

Posted 2010-04-30T08:55:02.627

Reputation: 101