Skip to content

Fix too low cpu_times_percent values when interval < ~1 second (#1586)#2413

Open
frankkusters wants to merge 2 commits into
giampaolo:masterfrom
frankkusters:master
Open

Fix too low cpu_times_percent values when interval < ~1 second (#1586)#2413
frankkusters wants to merge 2 commits into
giampaolo:masterfrom
frankkusters:master

Conversation

@frankkusters
Copy link
Copy Markdown

Summary

Description

Implement suggestion by @ulxasc in #1586 (comment) . This fixes that cpu_times_percent() reports much too low values if the interval is less than 1 second (with percpu=True) or less than 1/cpu_count() seconds (with percpu=False).

…aolo#1586)

Signed-off-by: Frank Kusters <frank.kusters@sioux.eu>
@giampaolo
Copy link
Copy Markdown
Owner

With this change I get one failure:

======================================================================
FAIL: psutil.tests.test_linux.TestMisc.test_cpu_steal_decrease
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/giampaolo/svn/psutil/psutil/tests/test_linux.py", line 1569, in test_cpu_steal_decrease
    self.assertNotEqual(sum(cpu_times_percent), 100.0)
AssertionError: 100.0 == 100.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Ubuntu 16.04.6 LTS] cpu_times_percent wrong idle values when percpu=True

2 participants