我需要在特定进程运行时获取系统的页面错误和磁盘IO。
我可以获得Page Faults但无法获得磁盘IO:
$arrayDIO = @()
$arrayPf = @()
$cmdProcess = start-process cmd -passthru
while (-not $cmdProcess.HasExited) {
$arrayDIO += %{ (Get-WmiObject Win32_PerfFormattedData_PerfProc_Process).IOWriteOperationsPerSec }
$arrayPf += %{ (Get-WmiObject Win32_PerfFormattedData_PerfOS_memory).PageFaultsPerSec }
sleep 2
}
$arrayPf | Measure-Object -Average -Maximum -Minimum | Out-File -Filepath C:\Details.txt
$arrayDIO | Measure-Object -Average -Maximum -Minimum | Out-File -Filepath C:\Details.txt -append
答案 0 :(得分:8)
使用内置命令获取性能数据,而不是 Get-WMIObject ,获取计数器:
Get-Counter '\Process(*)\IO Data Operations/sec'
Get-Counter '\Memory\Page Faults/sec'