GithubHelp home page GithubHelp logo

Comments (5)

RLYRLY avatar RLYRLY commented on July 22, 2024

After reading the latest psutil source code, the CPU utilization uses the GetSystemTimes API, but the calculation of the CPU utilization in the task manager after win10 has changed. The GetSystemTimes API has been a long time ago, and now it is replaced by a "performance counter", so there are inconsistencies.
The performance counter module under WMI obtains the process CPU utilization, which should be the same as what is displayed in the task manager.
https://learn.microsoft.com/en-us/windows/win32/perfctrs/performance-counters-portal
https://learn.microsoft.com/en-us/windows/win32/wmisdk/monitoring-performance-data

from psutil.

RLYRLY avatar RLYRLY commented on July 22, 2024

After doing a benchmark test, the CPU utilization output by psutil was 55%, and the result using a PowerShell script combined with Windows Performance Counters was 6%. The difference is nearly 10 times.

from psutil.

RLYRLY avatar RLYRLY commented on July 22, 2024

@giampaolo Hello, can you help me take a look?

from psutil.

giampaolo avatar giampaolo commented on July 22, 2024

Do you have any idea in what Windows version GetSystemTimes() was "obsoleted" by performance counters? Or put it in another way, any idea when Windows task manager started using PC? I'm fine with using PC on newer Windows versions and GetSystemTimes() for older ones. Feel free to make a PR if you know how to do this.

from psutil.

RLYRLY avatar RLYRLY commented on July 22, 2024

First of all, thank you for your answer. After reading the psutil documentation, I found that there is no problem in calculating the CPU utilization of a process in Windows. It was my misunderstanding.
Thanks again for your answer.
ps: I am currently testing on macOS and found that there is a problem with the calculation of CPU utilization, and I did not find a relevant explanation in the documentation. For details, see: #2411
@giampaolo

from psutil.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.