diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2017-01-19 18:34:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-19 18:34:02 +0100 |
commit | e8c3b6af1e8495367dfc3bcb5312996f73a4d5d1 (patch) | |
tree | 1c54d50fc16100db37709ad4b13d3ace9f474a0b | |
parent | db5776bf08127a90d4044b1133d53e738e9c144e (diff) | |
parent | e1a9376eb5fd5debd5f824688f43867693ec9604 (diff) | |
download | psutil-e8c3b6af1e8495367dfc3bcb5312996f73a4d5d1.tar.gz |
Merge pull request #950 from PierreF/windows-cpu-percent
Fix Process cpu_percent on Windows
-rw-r--r-- | CREDITS | 5 | ||||
-rw-r--r-- | HISTORY.rst | 2 | ||||
-rw-r--r-- | psutil/__init__.py | 9 |
3 files changed, 9 insertions, 7 deletions
@@ -420,3 +420,8 @@ I: 919 N: Max BĂ©langer W: https://github.com/maxbelanger I: 936 + +N: Pierre Fersing +C: France +E: pierre.fersing@bleemeo.com +I: 950 diff --git a/HISTORY.rst b/HISTORY.rst index 92413ec1..c6db2aa0 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -10,6 +10,8 @@ - 687_: [Linux] pid_exists() no longer returns True if passed a process thread ID. - 948_: cannot install psutil with PYTHONOPTIMIZE=2. +- 950_: [Windows] Process.cpu_percent() was calculated incorrectly and showed + higher number than real usage. 5.0.1 diff --git a/psutil/__init__.py b/psutil/__init__.py index f8ce48e6..7472ca8e 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -1007,13 +1007,8 @@ class Process(object): raise ValueError("interval is not positive (got %r)" % interval) num_cpus = cpu_count() or 1 - if POSIX: - def timer(): - return _timer() * num_cpus - else: - def timer(): - t = cpu_times() - return sum((t.user, t.system)) + def timer(): + return _timer() * num_cpus if blocking: st1 = timer() |