Closed GoogleCodeExporter closed 9 years ago
From psutil doc:
> When interval is 0.0 or None compares process times to system CPU
> times elapsed since last call, returning immediately. In this case
> is recommended for accuracy that this function be called with at
> least 0.1 seconds between calls.
That means the very first get_cpu_percent(interval=0) call will produce a
meaningless value as it has no previous value to compare against.
It therefore means you'll need at least TWO calls in order to produce a
meaningful result and wait some time between one call and the other.
Original comment by g.rodola
on 6 Jun 2013 at 12:30
Thank you for your quick answer Giampaolo. I forgot to tell that several calls,
for the same process, with 5 sec. intervals, always give 0.
Is it relevant to say that everytime I call get_cpu_percent, I create a new
instance of Process ?
Original comment by steve.ko...@gmail.com
on 6 Jun 2013 at 12:40
You should not create new Process instance every time. That's the problem.
Original comment by g.rodola
on 6 Jun 2013 at 1:04
Original comment by g.rodola
on 6 Jun 2013 at 2:08
Yes, you are right, this was the problem.
Original comment by steve.ko...@gmail.com
on 6 Jun 2013 at 2:08
Original issue reported on code.google.com by
steve.ko...@gmail.com
on 6 Jun 2013 at 12:26