Re: psutil does not match Task Manager

26 views
Skip to first unread message

Giampaolo Rodola'

unread,
May 20, 2013, 6:42:24 AM5/20/13
to psu...@googlegroups.com
Please do not cross post. You have created 2 messages on the ml and filed an issue on the bug tracker.
As for your question: the 2 *single* CPU usage values cannot be exactly the same if you compare them at an exact moment in time.
To have a meaningful result you should collect, say, 10 values with 1 second interval and then calculate the average as in (a + b + ...) / 10.

On Monday, May 20, 2013 8:39:08 AM UTC+2, senzh...@gmail.com wrote:
I have a task which needs to detect CPU usage of a process. 

I am using psutil library. When the program is running, Task Manager 
shows that it is using(35%), however when I use this code

import psutil
psutil.get_pid_list()
p = psutil.Process(3256)
print p.name
print  p.get_cpu_percent(interval=1)

it shows : CPU usage is 79.7%


Why there is such a big difference between Task Manager data and 
psutil? 
why psutil does not match Task Manager ?
Reply all
Reply to author
Forward
0 new messages