简体   繁体   English

查找CPU使用率最高的进程

[英]finding process with maximum CPU usage

To get all the process list im using Windows Management Instrumentation (WMI),and code is : 要使用Windows Management Instrumentation(WMI)获取所有进程列表,代码为:

import wmi
c = wmi.WMI ()

for process in c.Win32_Process ():
  print process.ProcessId, process.Name

But my question is how could i find the process which utilizes maximum CPU resource ? 但是我的问题是如何找到利用最大CPU资源的进程?

我建议不要使用特定于Windows的WMI,而是使用跨平台的psutil ,然后可以使用进程类 cpu_percent()方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM