问题描述
我有一个 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使用率最高的进程的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!