Files
linearvoid/scripts/loadtest/summarize-k6.ps1
T
zwitschi 33b6296c5e
CI / test (push) Successful in 2m50s
CI / docker (push) Successful in 5m12s
Refactor load testing scripts to support Bash and PowerShell
- Updated README.md to reflect changes in load testing commands and added usage examples for Bash scripts.
- Converted PowerShell load testing scripts to Bash equivalents for better cross-platform compatibility.
- Added new Bash scripts: run-loadtests.sh, summarize-artillery.sh, and summarize-k6.sh to mirror existing PowerShell functionality.
- Updated admin-api.js and ws-chat.yml for consistency and improved performance metrics reporting.
- Enhanced error handling and output formatting in summary scripts for better readability.
2026-09-02 19:47:34 +02:00

69 lines
1.8 KiB
PowerShell

#!/usr/bin/env pwsh
param(
[Parameter(Mandatory = $true)]
[string]$SummaryFile
)
$ErrorActionPreference = 'Stop'
if (-not (Test-Path $SummaryFile)) {
throw "Summary file not found: $SummaryFile"
}
$summary = Get-Content -Raw -Path $SummaryFile | ConvertFrom-Json
$metrics = $summary.metrics
if (-not $metrics) {
throw 'Invalid k6 summary file: missing metrics object.'
}
$endpoints = @('overview', 'analytics', 'chat_log', 'users')
function Get-MetricValue {
param(
[object]$Metric,
[string]$Key
)
if (-not $Metric) {
return $null
}
if (-not $Metric.values) {
return $null
}
$value = $Metric.values.$Key
if ($null -ne $value) {
return [double]$value
}
return $null
}
$globalDuration = Get-MetricValue -Metric $metrics.http_req_duration -Key 'p(95)'
$globalFailRate = Get-MetricValue -Metric $metrics.http_req_failed -Key 'rate'
Write-Output "k6 Summary: $SummaryFile"
if ($null -ne $globalDuration) {
Write-Output ("Global p95 duration (ms): {0:N2}" -f $globalDuration)
}
if ($null -ne $globalFailRate) {
Write-Output ("Global failure rate: {0:P2}" -f $globalFailRate)
}
Write-Output ''
$rows = foreach ($endpoint in $endpoints) {
$durationMetricName = "http_req_duration{endpoint:$endpoint}"
$failMetricName = "http_req_failed{endpoint:$endpoint}"
$durationP95 = Get-MetricValue -Metric $metrics.$durationMetricName -Key 'p(95)'
$failRate = Get-MetricValue -Metric $metrics.$failMetricName -Key 'rate'
[PSCustomObject]@{
Endpoint = $endpoint
P95Ms = if ($null -ne $durationP95) { [math]::Round($durationP95, 2) } else { $null }
FailurePct = if ($null -ne $failRate) { [math]::Round($failRate * 100, 4) } else { $null }
}
}
$rows | Format-Table -AutoSize | Out-String | Write-Output