25 lines
1.1 KiB
PowerShell
25 lines
1.1 KiB
PowerShell
# Best-effort system-counter capture alongside a bench run: total CPU utility
|
|
# + GPU compute-engine utilization (and NPU engines where the OS exposes them;
|
|
# absent counters are skipped by typeperf). Primary CPU metric remains the
|
|
# harness's in-process CPU-seconds — this is corroborating evidence.
|
|
param(
|
|
[string]$Out = "bench-results\counters.csv",
|
|
[int]$Seconds = 120
|
|
)
|
|
$ErrorActionPreference = "Stop"
|
|
New-Item -ItemType Directory -Force (Split-Path -Parent $Out) | Out-Null
|
|
$counters = @(
|
|
"\Processor Information(_Total)\% Processor Utility",
|
|
"\GPU Engine(*engtype_Compute)\Utilization Percentage",
|
|
"\NPU Engine(*)\Utilization Percentage"
|
|
)
|
|
# typeperf exits nonzero if ANY counter is invalid; probe each and keep the valid ones.
|
|
$valid = @()
|
|
foreach ($c in $counters) {
|
|
typeperf $c -sc 1 | Out-Null
|
|
if ($LASTEXITCODE -eq 0) { $valid += $c }
|
|
}
|
|
if ($valid.Count -eq 0) { throw "no usable counters on this machine" }
|
|
typeperf $valid -si 1 -sc $Seconds -f CSV -o $Out -y | Out-Null
|
|
Write-Output "captured $($valid.Count) counter set(s) for ${Seconds}s -> $Out"
|