LinuxQuestions.org

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

DavidA 11-26-2012 11:04 AM

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 02: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:24 PM.