| 123456789101112131415161718192021222324252627282930 |
- $ErrorActionPreference = "Stop"
- $reportDir = Join-Path $PSScriptRoot "reports"
- $htmlReport = Join-Path $reportDir "backend-performance-report.html"
- $csvPrefix = Join-Path $reportDir "backend-performance"
- $pendingFile = Join-Path $reportDir "backend_performance_pending.txt"
- New-Item -ItemType Directory -Path $reportDir -Force | Out-Null
- $locust = Get-Command locust -ErrorAction SilentlyContinue
- if ($null -eq $locust) {
- @(
- "ServicePilot 后端性能测试未执行",
- "原因:当前环境未安装 Locust 命令。",
- "安装命令:pip install -r requirements.txt",
- "执行命令:powershell -ExecutionPolicy Bypass -File .\run_backend_performance.ps1",
- "预期输出:reports/backend-performance-report.html 与 reports/backend-performance_*.csv"
- ) | Set-Content -Path $pendingFile -Encoding UTF8
- Write-Host "Locust 未安装,已生成待执行说明:$pendingFile"
- exit 1
- }
- & $locust.Source -f "$PSScriptRoot\locustfile_backend.py" `
- --host "http://localhost:3000" `
- --headless `
- -u 30 `
- -r 5 `
- -t 3m `
- --html "$htmlReport" `
- --csv "$csvPrefix"
|