param([string]$Application='src/AstroFrame.Desktop/bin/Release/net8.0/AstroFrame.Desktop.exe') $ErrorActionPreference='Stop' Set-Location (Split-Path $PSScriptRoot) $app=Join-Path $PWD $Application $projectPath=Join-Path $PWD 'projects/Sample Survey' $out=Join-Path $PWD 'docs/screenshots' New-Item -ItemType Directory -Force $out | Out-Null $records=@() foreach($case in @('pleiades','small','reject','dpi120','dpi144','nebula','all-flux','all-flux-small','smoke')) { $file=Join-Path $out $(if($case -eq 'smoke'){'smoke-checks.txt'}else{$case+'.png'}) $argsList=@($(if($case -eq 'smoke'){'--smoke'}else{'--capture'}),('"'+$projectPath+'"'),('"'+$file+'"')) if($case -ne 'smoke'){$argsList+=$(if($case -eq 'reject'){'reject'}elseif($case -eq 'nebula'){'Light_NGC 7000_30.0s_LP_20260816-222249.fit'}elseif($case -like 'all-flux*'){'all'}else{'pleiades'})} if($case -eq 'nebula'){$argsList[$argsList.Length-1]='"'+$argsList[$argsList.Length-1]+'"';$argsList+='nebula'} if($case -eq 'small'){$argsList+='1120'} if($case -eq 'dpi120'){$argsList+=@('1120','--dpi=120')} if($case -eq 'dpi144'){$argsList+=@('1120','--dpi=144')} if($case -eq 'all-flux-small'){$argsList+='1120'} if($case -like 'all-flux*'){$argsList+='"--metric=Forced stellar flux"'} $process=Start-Process -FilePath $app -ArgumentList $argsList -WindowStyle Hidden -PassThru $timer=[Diagnostics.Stopwatch]::StartNew();$workingPeak=0L;$privatePeak=0L while(!$process.HasExited) { $process.Refresh() $workingPeak=[math]::Max($workingPeak,$process.WorkingSet64) $privatePeak=[math]::Max($privatePeak,$process.PrivateMemorySize64) if($privatePeak -gt 1536MB -or $timer.Elapsed.TotalSeconds -gt 25){Stop-Process -Id $process.Id -Force;throw "Resource/time bound exceeded for $case"} Start-Sleep -Milliseconds 100 } $records+=[pscustomobject]@{case=$case;peakWorkingMB=[math]::Round($workingPeak/1MB,1);peakPrivateMB=[math]::Round($privatePeak/1MB,1);exitCode=$process.ExitCode;seconds=[math]::Round($timer.Elapsed.TotalSeconds,2)} $records | ConvertTo-Json | Set-Content (Join-Path $out 'resource-checks.json') if($process.ExitCode -ne 0){throw "Desktop verification failed for $case (exit $($process.ExitCode))"} if(!(Test-Path $file)){throw "Missing verification output for $case"} } $records | ConvertTo-Json | Set-Content (Join-Path $out 'resource-checks.json') $records | Format-Table -AutoSize