【问题标题】:What is the " Unit " of time returned by psutil.cpu_times()?psutil.cpu_times() 返回的时间“单位”是多少?
【发布时间】:2019-08-25 03:59:55
【问题描述】:

是秒吗?我正在尝试将它与top -n 1 | grep Cpu 命令的输出相匹配,它们看起来不同!

>>> psutil.cpu_times()
scputimes(user=678.99, nice=2.15, system=405.34, idle=414554.14, iowait=12.95, irq=0.0, softirq=2.43, steal=95.2, guest=0.0, guest_nice=0.0)
>>> exit()
[root@Server]# top -n 1 | grep Cpu
%Cpu(s):  0.0 us,  0.0 sy,  0.0 ni,100.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st

【问题讨论】:

    标签: python linux centos psutil cpu-time


    【解决方案1】:

    是的,它是几秒钟。参考文档在这里:

    https://psutil.readthedocs.io/en/latest/#psutil.cpu_times

    每个属性代表 CPU 在给定模式下花费的秒数。

    有关top 给您的描述,请参阅此答案:

    https://superuser.com/questions/575202/understanding-top-command-in-unix

    您从 top 看到的值是百分比,因此它们与您从 psutil 看到的值不一致

    老实说,目前还不清楚您要在这里实现什么目标。

    【讨论】:

      猜你喜欢
      • 2012-05-26
      • 1970-01-01
      • 2022-01-14
      • 2011-10-19
      • 1970-01-01
      • 2011-04-20
      • 1970-01-01
      • 2011-10-11
      • 2015-11-10
      相关资源
      最近更新 更多