whi147
V2EX  ›  Windows

求 win10 cpu 使用率,要与任务管理器-性能中值一致

  •  
  •   whi147 · Jan 5, 2021 via iPhone · 3138 views
    This topic created in 2127 days ago, the information mentioned may be changed or developed.

    我用两套 api 都算出来是有误差 5-10 之间

    3 replies  •  2021-01-05 23:51:16 +08:00
    ysc3839
    ysc3839
    Jan 5, 2021
    1
    读 Performance Counter 里面 Processor Information 下面的 "% Processor Utility" 这一项,同时在读取到的值超过 100 时,把它当成 100 。
    可以运行 perfmon.msc 看看是否和任务管理器一样。

    参考资料
    https://docs.microsoft.com/en-us/troubleshoot/windows-client/performance/cpu-usage-exceeds-100
    ysc3839
    ysc3839
    Jan 5, 2021
    2
    至于怎么编程读取 Performance Counter,帮你找了个 example
    https://docs.microsoft.com/en-us/windows/win32/perfctrs/reading-performance-data-from-a-log-file
    whi147
    whi147
    OP
    Jan 5, 2021 via iPhone
    3
    @ysc3839 谢谢,我明天试一下
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3212 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 11:11 · PVG 19:11 · LAX 03:11 · JFK 06:11
    ♥ Do have faith in what you're doing.