param([int]$Samples=601,[int]$IntervalSeconds=2) $testRoot=Split-Path -Parent $PSScriptRoot $outputPath=Join-Path $testRoot 'private-raw\resource_samples.jsonl' $clock=[Diagnostics.Stopwatch]::StartNew() for ($sampleIndex=0;$sampleIndex -lt $Samples;$sampleIndex++) { $condition='unspecified' $conditionFile=Join-Path $testRoot 'evidence\current_condition.json' if(Test-Path -LiteralPath $conditionFile){try{$condition=(Get-Content -LiteralPath $conditionFile -Raw | ConvertFrom-Json).label}catch{}} $processRows=@(Get-Process -Name SingLinkVPN,singcore,SingCoreHelperService,SingLinkProxyGuard -ErrorAction SilentlyContinue | Select-Object ProcessName,Id,CPU,WorkingSet64,PrivateMemorySize64) [ordered]@{at=(Get-Date -Format o);elapsed_seconds=$clock.Elapsed.TotalSeconds;condition=$condition;processes=$processRows} | ConvertTo-Json -Depth 5 -Compress | Add-Content -LiteralPath $outputPath -Encoding UTF8 if($sampleIndex+1 -lt $Samples){$delay=[Math]::Max(0,(($sampleIndex+1)*$IntervalSeconds)-$clock.Elapsed.TotalSeconds);Start-Sleep -Milliseconds ([int]($delay*1000))} }