kiranvizru / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

difference between p.get_cpu_percent() and p.as_dict()['cpu_percent'] #437

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. run a heavy process getting pid
2. run python
3. import psutil
4. p=psutil.Process(<pid>)
5. print "%s %s"%( p.get_cpu_percent(), p.as_dict()['cpu_percent'])

What is the expected output?
a couple of equal numbers

What do you see instead?
the fist one is ok, but second is always 0.0

What version of psutil are you using? What Python version?
Python 2.7 with psutil 1.0.1

On what operating system? Is it 32bit or 64bit version?
Debian Sid 64bit, but I see the same on Sarge.

Please provide any additional information below.

Original issue reported on code.google.com by cippin...@gmail.com on 27 Sep 2013 at 7:09

GoogleCodeExporter commented 9 years ago
Those are percentages taken in two different times, and also with two different 
timeouts (see get_cpu_percent() doc).
That's not how CPU percentage is supposed to be determined by using psutil.
If you still have doubts please post on the ml. Closing out as invalid.

Original comment by g.rodola on 27 Sep 2013 at 7:34

GoogleCodeExporter commented 9 years ago
Thanks for the answer.

Original comment by cippin...@gmail.com on 27 Sep 2013 at 7:59