根据滴答数计算 CPU 使用率

发布于 2024-11-03 08:14:36 字数 152 浏览 2 评论 0原文

当我知道在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

标点 2024-11-10 08:14:36

您的程序无法知道这一点,因为它根本不知道它何时不运行。当它运行时,它只是使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文