Closed GoogleCodeExporter closed 8 years ago
> Expected: each call should give cpu usage since previous call.
> Actual: gives cpu usage since module import.
I think you're misinterpreting the code.
This is true only *the first time* the function is called.
Since then times are compared against previous function call.
Original comment by g.rodola
on 3 Jun 2011 at 7:34
The current code looks like this:
if blocking:
t1 = cpu_times()
time.sleep(interval)
else:
t1 = _last_cpu_times
t1_all = sum(t1)
t1_busy = t1_all - t1.idle
t2 = cpu_times()
t2_all = sum(t2)
t2_busy = t2_all - t2.idle
_last_cpu_times = t1
So if you are using the non-blocking code, it looks like we set t1 =
_last_cpu_times and then later we are setting _last_cpu_times = t1 without
modifying it, so it's effectively a no-op. I guess this got introduced when
adding the blocking code path.
Original comment by jlo...@gmail.com
on 3 Jun 2011 at 4:28
You guys are right, sorry.
This is now fixed in r981.
Original comment by g.rodola
on 3 Jun 2011 at 5:16
Original comment by g.rodola
on 27 Jun 2011 at 5:52
Original comment by g.rodola
on 8 Jul 2011 at 7:07
[deleted comment]
Updated csets after the SVN -> Mercurial migration:
r981 == revision a415d2627242
Original comment by g.rodola
on 2 Mar 2013 at 12:00
Original issue reported on code.google.com by
philip.r...@gmail.com
on 3 Jun 2011 at 2:23