[英]Getting the total CPU usage in python 3 on windows
I am trying to write a program that can measure the overall CPU usage.我正在尝试编写一个可以测量总体 CPU 使用率的程序。
I tried using psutil.cpu_percent()
, but it is returning the CPU usage for only the python process.我尝试使用
psutil.cpu_percent()
,但它仅返回 python 进程的 CPU 使用率。
import psutil
psutil.cpu_percent(5)
Count it for multiple seconds, will return the average cpu usage in 5 seconds.统计多秒,会返回5秒后的平均cpu使用率。 psutil.cpu_percent() Only gets the usage in the current moment, Which can go from 1 to 50+ in a few ms.
psutil.cpu_percent() 只获取当前时刻的使用情况,可以在几毫秒内从 1 到 50+ go。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.