Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
qemu32
V2EX  ›  Linux

Linux c 编程问题请教,有没有什么简单的办法快速得到本机当前总的 cpu 负载?

  •  
  •   qemu32 · Sep 18, 2022 · 2637 views
    This topic created in 1351 days ago, the information mentioned may be changed or developed.

    目前查到的资料只能是通过读取 /proc/stat 来计算,我想找个现成的方法,直接得到最近 1 毫秒内本机总的 cpu 负载,最好是直接以一个 0 到 100 的数值来表示,0 表示完全空闲,100 表示满载。

    这个总负载的含义是指除了执行 idle 任务之外的所有时间都算进来。

    1 replies    2022-09-18 23:57:28 +08:00
    chu1337
        1
    chu1337  
       Sep 18, 2022
    man getloadavg
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3916 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 05:07 · PVG 13:07 · LAX 22:07 · JFK 01:07
    ♥ Do have faith in what you're doing.