Closed GoogleCodeExporter closed 9 years ago
From the doc:
When interval is 0.0 or None compares process times to system CPU
times elapsed since last call, returning immediately.
In summary, you are not supposed to expect > 0.0 percentage if you call
get_cpu_percent(interval=0) rapidly or do nothing between a call and another.
See this:
>>> import psutil, os
>>> p = psutil.Process(os.getpid())
>>> p.get_cpu_percent(interval=0) # first call
0.0
>>> for x in range(10000000):
... pass
...
>>>
>>> # second call (compares CPU times elapsed since first call)
>>> p.get_cpu_percent(interval=0)
8.7
>>>
Original comment by g.rodola
on 30 Jan 2012 at 3:04
Original issue reported on code.google.com by
nicolash...@gmail.com
on 30 Jan 2012 at 2:52