问题描述
我有一个 Samurize 配置,它显示类似于任务管理器的 CPU 使用率图表.
I have a Samurize config that shows a CPU usage graph similar to Task manager.
如何同时显示当前 CPU 使用百分比最高的进程名称?
How do I also display the name of the process with the current highest CPU usage percentage?
我希望每秒最多更新一次.Samurize 可以调用命令行工具并将其输出显示在屏幕上,因此这也是一种选择.
I would like this to be updated, at most, once per second. Samurize can call a command line tool and display it's output on screen, so this could also be an option.
进一步说明:
我研究过编写自己的命令行 c# .NET 应用程序来枚举从 System.Diagnostics.Process.GetProcesses() 返回的数组,但 Process 实例类似乎不包含 CPU 百分比属性.
I have investigated writing my own command line c# .NET application to enumerate the array returned from System.Diagnostics.Process.GetProcesses(), but the Process instance class does not seem to include a CPU percentage property.
我可以用某种方式计算吗?
Can I calculate this in some way?
推荐答案
使用 PowerShell:
With PowerShell:
Get-Process | Sort-Object CPU -desc | Select-Object -first 3 | Format-Table CPU,ProcessName -hidetableheader
返回有点像:
16.8641632 System
12.548072 csrss
11.9892168 powershell
这篇关于cpu使用率最高的进程名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!