有没有任何命令或可能的方式来知道在Windows操作系统中使用的命令行或批处理脚本的CPU利用率?
要确定一般的用法,你可以使用mcstellar和warren的答案。 您也可以选择:
列出所有进程:
typeperf "\Process(*)\% Processor Time" -sc 1
列出所有过程,每隔10秒取5个样品:
typeperf "\Process(*)\% Processor Time" -si 10 -sc 5
如果你想要一个特定的过程,例如Rtvscan:
typeperf "\Process(Rtvscan)\% Processor Time" -si 10 -sc 5
我发现在一段时间内只监视所有的流程活动是非常有用的。 然后,我可以将其转储到csv文件并在电子表格中进行过滤以远程诊断问题。
下面给我5分钟(间隔10秒)的所有过程。 数据不仅包括处理器时间百分比,还包括IO,内存,分页等。
typeperf -qx "\Process" > config.txt
typeperf -cf config.txt -o perf.csv -f CSV -y -si 10 -sc 60
要以1秒的间隔进行监控,请使用:
typeperf "\processor(_total)\% processor time"
仅针对当前的使用情况,请使用:
typeperf -sc 1 "\processor(_total)\% processor time"
这里有一个vbscript,显示每个进程的CPU利用率
strComputer ="." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colProcess = objWMIService.ExecQuery("Select * from Win32_PerfFormattedData_PerfProc_Process",,48) For Each obj in colProcess If obj.Name <> "Idle" And obj.Name <> "_Total" Then WScript.echo obj.Name & "," & obj.PercentProcessorTime End If Next
另存为showcpu.vbs并在命令行上运行
c:\test> cscript //nologo showcpu.vbs
从命令行? 看看PsTools套件中的PsList。