How can I monitor the CPU usage of one process over a period of time?
Solution 1:
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.
Solution 2:
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.
Solution 3:
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