使用Windows命令行获取每个内核的CPU使用率 [英] Get CPU usage for each core using the windows command line
本文介绍了使用Windows命令行获取每个内核的CPU使用率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以打印系统中每个内核的当前CPU使用情况?
Is it possible to print the current CPU usage for each core in the system?
这是到目前为止使用powershell的结果:
This is what I have so far using powershell:
Get-WmiObject -Query "select Name, PercentProcessorTime from Win32_PerfFormattedData_PerfOS_Processor"
推荐答案
可以使用以下powershell命令完成:
It can be be done using the following powershell command:
(Get-WmiObject -Query "select Name, PercentProcessorTime from Win32_PerfFormattedData_PerfOS_Processor") | foreach-object { write-host "$($_.Name): $($_.PercentProcessorTime)" };
也可以创建一个名为 get_cpu_usage.ps1 $ c $的文件c>,内容为:
Also you could create a file called get_cpu_usage.ps1
with the contents:
while ($true)
{
$cores = (Get-WmiObject -Query "select Name, PercentProcessorTime from Win32_PerfFormattedData_PerfOS_Processor")
$cores | foreach-object { write-host "$($_.Name): $($_.PercentProcessorTime)" };
Start-Sleep -m 200
}
然后使用以下命令运行它: / p>
Then run it using:
powershell -executionpolicy bypass "get_cpu_usage.ps1"
这篇关于使用Windows命令行获取每个内核的CPU使用率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文