- docs/moysklad-pos-startup.md: прямой замер «Кассы МойСклад» (Celeron N4120, 99–113 с до готовности; каталог перезаписывается целиком, полный JSON+FTS) — подтверждённые причины, не догадки. - docs/pos-progress.md: раздел «Мгновенный старт» — что сделано (касса из локальной базы + фоновый синк, дельта остатков, gzip-каталог ×7.3, синк вне UI-потока) + таблица замеров (Linux/стенд + Win11 VM + 1 ядро как прокси Celeron). Цель <2 с тёплый старт на слабом CPU достигнута (<1 с). Серверный кэш снимка осознанно не делали (риск памяти, путь «раз на установку»). - deploy/pos-install.ps1: установщик Windows (исключение Defender + прогрев + ярлык); холодный старт 10 с → 4,5 с. deploy/pos-win-measure.ps1 — скрипт замеров на VM. - docs/pos.md: обновлён раздел первого запуска + варианты/стоимость подписи exe (не покупали). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
53 lines
2.8 KiB
PowerShell
53 lines
2.8 KiB
PowerShell
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 ==="
|