把 XH巡课 的当前可运行版本放进仓库,方便后续继续改并同步。
This commit is contained in:
commit
6e5107f1b6
134 files changed
+11284
No files matched your search
@@ -0,0 +1,23 @@
|
||||
# 对已登录的管理接口做小规模并发,记录成功数和耗时。这不是 300 路直播测试。
|
||||
$ErrorActionPreference = "Stop"
|
||||
$login = Invoke-RestMethod -Method POST -Uri "http://localhost:8080/api/auth/login" -ContentType "application/json" -Headers @{ "X-XH-Request" = "1" } -Body '{"account":"admin","password":"ChangeMe_Admin_2026!"}'
|
||||
$token = $login.data.accessToken
|
||||
$jobs = 1..50 | ForEach-Object {
|
||||
Start-Job -ScriptBlock {
|
||||
param($token)
|
||||
$watch = [Diagnostics.Stopwatch]::StartNew()
|
||||
try {
|
||||
Invoke-RestMethod -Method GET -Uri "http://localhost:8080/api/dashboard" -Headers @{ Authorization = "Bearer $token"; "X-XH-Request" = "1" } | Out-Null
|
||||
"ok $($watch.ElapsedMilliseconds)"
|
||||
} catch {
|
||||
"fail $($watch.ElapsedMilliseconds)"
|
||||
}
|
||||
} -ArgumentList $token
|
||||
}
|
||||
$results = $jobs | Wait-Job | Receive-Job
|
||||
$jobs | Remove-Job | Out-Null
|
||||
$ok = @($results | Where-Object { $_ -like "ok *" })
|
||||
$times = $ok | ForEach-Object { [int]($_ -split " ")[1] }
|
||||
$sorted = $times | Sort-Object
|
||||
$p95 = if ($sorted.Count -gt 0) { $sorted[[Math]::Min($sorted.Count - 1, [Math]::Floor($sorted.Count * 0.95))] } else { 0 }
|
||||
Write-Output "LOAD_OK success=$($ok.Count) fail=$($results.Count - $ok.Count) max=$($sorted[-1]) p95=$p95"
|
||||
Reference in new issue
Block a user