LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Question regarding /proc/stat (cpu load measurement) (http://www.linuxquestions.org/questions/programming-9/question-regarding-proc-stat-cpu-load-measurement-4175438777/)

DavidA 11-26-2012 12:04 PM

Question regarding /proc/stat (cpu load measurement)
 
Hi,

I am working on an embedded Linux project and need to measure cpu load programmatically. General advice seems to be to use /proc/stat for this purpose. I understand the algorithm to do that. However, I am confused by the results I am seeing.

I am running one user process and 'top' shows that it is consuming 12% of the cpu.

However, if I repeatedly execute 'cat /proc/stat' from the command line, the first number after 'cpu', which should be the number of 'user' jiffies, barely changes. The 'idle' value (4th number) does change appreciably.

Why is the 'user' value not changing?

Best regards

David

theNbomr 11-26-2012 03:19 PM

As I understand it, the value shown by top is a percentage of the non-idle time, whereas the numbers you see in /proc/stat are absolute times.
--- rod.


All times are GMT -5. The time now is 06:18 AM.