Calculating CPU Usage
I have a question about calculating CPU usage for a certain process on Linux. I need to be able to calculate CPU utilization for a process and its threads given a PID or a name. Unfortunately, "top" is slow and my version of "ps" does not support calculating CPU usage in the raw mode. For this particular purpose, I'd like to calculate CPU usage using either system programming or by having some sort of a script that reads through /proc filesystem. Does anybody know how to do this by using any of those or other methods? Many thanks in advance.
At your prompt type
(or whatever your program is called)
When it exits, the shell will print out some timing information.
This may work, unfortunately, I need real time stats update every second or so in order to plot a graph of CPU utilization. I am trying to benchmark a server and I am interested in how it handles QPS over time.