![]() |
| | #1 |
| Registered User Join Date: Aug 2005
Posts: 2
| 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. --V |
| vitaliy is offline | |
| | #2 |
| and the hat of vanishing Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,214
| At your prompt type time ./a.out (or whatever your program is called) When it exits, the shell will print out some timing information.
__________________ If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut. Up to 8Mb PlusNet broadband from only £5.99 a month! |
| Salem is offline | |
| | #3 |
| Registered User Join Date: Aug 2005
Posts: 2
| 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. Thank you. |
| vitaliy is offline | |
| | #4 |
| and the hat of vanishing Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,214
|
__________________ If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut. Up to 8Mb PlusNet broadband from only £5.99 a month! |
| Salem is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reduce CPU usage | patrick22 | Windows Programming | 9 | 07-10-2009 02:13 PM |
| questions on multiple thread programming | lehe | C Programming | 11 | 03-27-2009 07:44 AM |
| Net cpu usage of pthreads?! | mynickmynick | C++ Programming | 15 | 09-26-2008 07:59 AM |
| Calculating CPU Usage | smarta_982002 | C Programming | 7 | 03-20-2008 03:28 AM |
| CPU Usage so high | X PaYnE X | Windows Programming | 9 | 12-21-2003 03:07 AM |