# Manual harness: repeatedly processes real + synthetic photos in a single process, # mirroring how the service handles many employees per sync cycle. # C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -File Tests\run_photo_soak.ps1 -Rounds 15 param([int]$Rounds = 15) $dir = Join-Path $PSScriptRoot '..\bin\Debug\net48' | Resolve-Path $log = Join-Path $env:TEMP 'hik_soak.txt' Set-Content -Path $log -Value "soak start rounds=$Rounds" [System.AppDomain]::CurrentDomain.add_AssemblyResolve({ param($sender, $e) $name = ($e.Name -split ',')[0] $path = Join-Path $dir "$name.dll" if (Test-Path $path) { return [System.Reflection.Assembly]::LoadFrom($path) } return $null }) $asm = [System.Reflection.Assembly]::LoadFrom((Join-Path $dir 'HikvisionAttendanceService.exe')) $type = $asm.GetType('HikvisionAttendanceService.EmployeePhotoFaceProcessor') $method = $type.GetMethod('Process', [System.Reflection.BindingFlags]'Static,Public,NonPublic') Add-Type -AssemblyName System.Drawing $samples = @{} foreach ($id in '142554', '144154', '149903') { $p = Join-Path $env:TEMP "hik_photo_test\$id.source.jpeg" if (Test-Path $p) { $samples[$id] = [System.IO.File]::ReadAllBytes($p) } } $bmp = New-Object System.Drawing.Bitmap 400, 400, ([System.Drawing.Imaging.PixelFormat]::Format24bppRgb) $g = [System.Drawing.Graphics]::FromImage($bmp); $g.Clear([System.Drawing.Color]::SlateGray); $g.Dispose() $ms = New-Object System.IO.MemoryStream $bmp.Save($ms, [System.Drawing.Imaging.ImageFormat]::Jpeg) $samples['gray-noface'] = $ms.ToArray() $samples['garbage'] = [byte[]]@(1, 2, 3, 4, 5) $samples['empty'] = [byte[]]@() $proc = [System.Diagnostics.Process]::GetCurrentProcess() $sw = [System.Diagnostics.Stopwatch]::StartNew() $counts = @{} for ($i = 1; $i -le $Rounds; $i++) { foreach ($key in $samples.Keys) { $bytes = [byte[]]$samples[$key] $r = $method.Invoke($null, @(, $bytes)) $k = "$key=$($r.Status)" if (-not $counts.ContainsKey($k)) { $counts[$k] = 0 } $counts[$k]++ } } $sw.Stop() $proc.Refresh() foreach ($k in ($counts.Keys | Sort-Object)) { Add-Content -Path $log -Value "$k count=$($counts[$k])"; Write-Host "$k count=$($counts[$k])" } $line = "totalMs=$($sw.ElapsedMilliseconds) perCallMs=$([math]::Round($sw.ElapsedMilliseconds / ($Rounds * $samples.Count), 1)) workingSetMB=$([math]::Round($proc.WorkingSet64 / 1MB, 1)) handles=$($proc.HandleCount)" Add-Content -Path $log -Value $line Write-Host $line