[英]What is the “ Unit ” of time returned by psutil.cpu_times()?
Is it seconds? 是秒吗? I am trying to match it with the output of top -n 1 | grep Cpu
我试图将它与top -n 1 | grep Cpu
的输出相匹配 top -n 1 | grep Cpu
command, and they look different! 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
Yes, it's seconds. 是的,这是秒。 The reference docs for this are here: 这里的参考文档在这里:
https://psutil.readthedocs.io/en/latest/#psutil.cpu_times https://psutil.readthedocs.io/en/latest/#psutil.cpu_times
Every attribute represents the seconds the CPU has spent in the given mode. 每个属性表示CPU在给定模式下花费的秒数。
For a description of the top
is giving you, refer to this answer: 有关top
的描述,请参阅此答案:
https://superuser.com/questions/575202/understanding-top-command-in-unix https://superuser.com/questions/575202/understanding-top-command-in-unix
The values you're seeing from top
are percentages, hence they don't align with the values you're seeing from psutil
您从top
看到的值是百分比,因此它们与您从psutil
看到的值psutil
To be honest, it's not clear what you're trying to achieve here. 说实话,目前尚不清楚你在这里想要达到的目标。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.