test(bench): typeperf CPU/GPU/NPU counter capture script

This commit is contained in:
iamdoubz committed 2026-07-15 21:35:43 -05:00
1 parent 965f1adc86
commit 4dddcdfe1a
1 file changed
+24
+24
View File
@@ -0,0 +1,24 @@
# 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"