Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

k6diff

CLI tool to parse and diff k6 performance test results.

Compare two k6 runs side-by-side with aligned metrics, color-coded changes, and compact matrix output.

Features

  • Parse k6 text output (stdout) and handleSummary() JSON
  • Diff two results in a compact matrix table (avg / med / p95 per metric)
  • Color-coded changes: dim (< 5%), yellow (5-30%), green/red (> 30%)
  • Multiplier annotation for large improvements (e.g. (2.3x))
  • Threshold change tracking (resolved / newly crossed)
  • Export to JSON / TSV for further analysis
  • Auto-detect input format (text or JSON)

Installation

cargo install --git https://github.com/azihsoyn/k6diff.git

Or build from source:

git clone https://github.com/azihsoyn/k6diff.git
cd k6diff
cargo install --path .

Usage

Diff two results

k6diff result_before.txt result_after.txt
┌──────────────────────┬───────────────────────────────────┬──────────────────────────┬─────────────────────────────────┐
│ metric               │                avg                │           med            │               p95               │
├──────────────────────┼───────────────────────────────────┼──────────────────────────┼─────────────────────────────────┤
│ aggregate_time       │  748.6ms -> 320.1ms -57.2% (2.3x) │   120ms ->   95ms -20.8% │    3.65s ->  1.2s -67.1% (3.0x) │
│ dashboard_load_time  │    2.36s ->   1.85s -21.6%        │   831ms ->  650ms -21.8% │   16.03s -> 10.5s -34.5% (1.5x) │
│ http_req_duration    │ 290.09ms -> 210.5ms -27.4%        │ 63.82ms -> 52.1ms -18.4% │ 383.53ms -> 290ms -24.4%        │
│ signin_time          │  76.48ms ->  65.2ms -14.7%        │    85ms ->   72ms -15.3% │  106.1ms ->  98ms  -7.6%        │
└──────────────────────┴───────────────────────────────────┴──────────────────────────┴─────────────────────────────────┘

Options

# Filter: show only changes above 10%
k6diff result1.txt result2.txt -t 10

# Verbose: show all metrics with bar graph
k6diff result1.txt result2.txt --verbose

# JSON output
k6diff result1.txt result2.txt -f json

# Save to file
k6diff result1.txt result2.txt -o diff.txt

Parse / convert

# Convert k6 output to JSON
k6diff parse result.txt -f json -o result.json

# Convert to TSV (for spreadsheets)
k6diff parse result.txt -f tsv

# Pretty-print as table
k6diff parse result.txt

Saving k6 results

Recommended: clean text output

k6 run --no-color --quiet script.js 2>&1 | tee result.txt
  • --no-color removes ANSI escape codes
  • --quiet suppresses progress bars

k6diff can also handle raw output with ANSI codes and progress bars (they are stripped automatically), but clean output is recommended.

Alternative: handleSummary() JSON

Add to your k6 script:

import { textSummary } from 'https://jslib.k6.io/k6-summary/0.0.1/index.js';

export function handleSummary(data) {
  return {
    'result.json': JSON.stringify(data, null, 2),
    stdout: textSummary(data, { indent: ' ', enableColors: false }),
  };
}

k6diff auto-detects the format, so you can mix text and JSON:

k6diff result.txt result.json

Color coding

Change Improvement (faster) Regression (slower)
< 5% dim dim
5-30% green yellow
> 30% green bold red

License

MIT

About

CLI tool to parse and diff k6 performance test results

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages