根据滴答数计算 CPU 使用率
当我知道在 user、nice、sys、idle 和 irq 中花费的 CPU 滴答数时,如何以百分比计算 CPU 使用率?例如刻度值的输出如下:
449760 3590 282250 298612690 0
但我想知道它们的百分比值。有这个计算的公式吗?
How can CPU usage be calculated in % when I know the number of CPU ticks spent in: user, nice, sys, idle, and irq? For example the output of tick values is like this:
449760
3590
282250
298612690
0
but I want to know their percentage value. Is there some formula for this calculation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的程序无法知道这一点,因为它根本不知道它何时不运行。当它运行时,它只是使用 100% 的 CPU。在这种情况下,百分比仅在相对测量时才有意义,但您尚未指定相对于 WHAT 的值。
Your program can't know that because it simply doesn't know when it's not running. And when it IS running, it simply uses 100% of the CPU. In this case, precentages make sense only as relative measurements, but you haven't specified relative to WHAT.