param([string]$Url, [string]$User, [string]$Pass) $ErrorActionPreference = 'Continue' function TMeasure($block) { (Measure-Command $block).TotalMilliseconds } Write-Output "=== Windows POS startup measurement ===" Write-Output ("CPU: " + (Get-CimInstance Win32_Processor).Name) $defAV = (Get-CimInstance -Namespace root/SecurityCenter2 -Class AntiVirusProduct -ErrorAction SilentlyContinue | Select-Object -First 1 -Expand displayName) Write-Output ("AV: " + $defAV) $rt = (Get-MpPreference -ErrorAction SilentlyContinue).DisableRealtimeMonitoring Write-Output ("Defender realtime disabled: " + $rt) $zip = "C:\Users\tester\pos-win.zip" function FreshUnpack($dir) { if (Test-Path $dir) { Remove-Item -Recurse -Force $dir } Expand-Archive -Path $zip -DestinationPath $dir -Force } # 1. COLD: свежая распаковка, первый запуск exe (Defender сканирует неподписанный exe+dll) FreshUnpack "C:\pos-cold" $exe = "C:\pos-cold\foodmarket.Pos.exe" $cold = TMeasure { & $exe --smoke | Out-Null } Write-Output ("COLD start (--smoke, Defender on, no exclusion): {0:N0} ms" -f $cold) # 2. WARM: повторные запуски (Defender закэшировал) $warm = @() for ($i=0; $i -lt 3; $i++) { $warm += (TMeasure { & $exe --smoke | Out-Null }) } Write-Output ("WARM start x3 (--smoke): " + (($warm | ForEach-Object { '{0:N0}' -f $_ }) -join ', ') + " ms") # 3. Defender exclusion (нужны права админа) + свежая распаковка + cold $exclOk = $true try { Add-MpPreference -ExclusionPath "C:\pos-excl" -ErrorAction Stop } catch { $exclOk = $false; Write-Output ("Defender exclusion FAILED (нужен админ): " + $_.Exception.Message) } if ($exclOk) { FreshUnpack "C:\pos-excl" $exe2 = "C:\pos-excl\foodmarket.Pos.exe" $coldExcl = TMeasure { & $exe2 --smoke | Out-Null } Write-Output ("COLD start WITH Defender exclusion: {0:N0} ms" -f $coldExcl) } # 4. Bench каталога (сеть+запись+тёплый+дельта) — нормально и на 1 ядре if ($Url -and $User -and $Pass) { $out = "C:\pos-cold\bench.txt" Write-Output "--- bench NORMAL (all cores) ---" & $exe --bench $Url $User $Pass 2>&1 | Where-Object { $_ -match 'bench' } | ForEach-Object { Write-Output $_ } Write-Output "--- bench 1 CPU core (Celeron N4120 прокси) ---" $psi = Start-Process -FilePath $exe -ArgumentList @('--bench',$Url,$User,$Pass) -PassThru -RedirectStandardOutput $out -NoNewWindow Start-Sleep -Milliseconds 300 try { $psi.ProcessorAffinity = [IntPtr]1; $psi.PriorityClass = 'BelowNormal' } catch { Write-Output ("affinity set failed: " + $_.Exception.Message) } $psi.WaitForExit() Get-Content $out | Where-Object { $_ -match 'bench' } | ForEach-Object { Write-Output $_ } } Write-Output "=== done ==="