Skip to content

Ci readiness - #153

Open
mokshasoft wants to merge 4 commits into
giltene:masterfrom
mokshasoft:ci-readiness
Open

Ci readiness#153
mokshasoft wants to merge 4 commits into
giltene:masterfrom
mokshasoft:ci-readiness

Conversation

@mokshasoft

Copy link
Copy Markdown

Add JSON output and configurable percentiles for CI integration

This PR adds two features to make wrk2 easier to use in CI/CD pipelines and automated testing:

JSON Output (-o)

# Output to file
wrk2 -t4 -c100 -d30s -R1000 -o results.json http://localhost:8080

# Output to stdout (pipe to jq, etc.)
wrk2 -t4 -c100 -d30s -R1000 -o - http://localhost:8080 | jq '.rps'

The JSON includes:

  • Target URL and test configuration (threads, connections, duration, rate)
  • Request count, bytes transferred, actual duration
  • Requests/sec and bytes/sec
  • Full latency histogram (min, max, mean, stdev, percentiles)
  • Error breakdown (connect, read, write, status, timeout)
  • Uncorrected latency (when -U flag is used)

Configurable Percentiles (-p)

wrk2 -t4 -c100 -d30s -R1000 -p 50,95,99 -L http://localhost:8080

Default percentiles remain: 50, 75, 90, 99, 99.9, 99.99, 99.999, 100

Other improvements

  • ARM64 support: Removed unnecessary x86intrin.h include that broke builds on Apple Silicon and other ARM platforms
  • Nix flake: Added flake.nix for reproducible builds
  • Makefile: Added USE_SYSTEM_LUAJIT=1 option with pkg-config support

All changes are backward compatible - existing scripts and usage patterns work unchanged.

Features:
- Add -o/--output option for JSON output (file or stdout with "-")
- Add -p/--percentiles option for custom latency percentiles
- JSON includes: requests, errors, bytes, duration, rps, latency stats

Build improvements:
- Add USE_SYSTEM_LUAJIT option to use system LuaJIT instead of bundled
- Support pkg-config for LuaJIT and OpenSSL, with manual path fallback
- Add flake.nix for nix build support (works on macOS ARM64)
- Fix ARM64 compatibility (conditional x86intrin.h include)
- Fix newer LuaJIT API compatibility (luaL_reg -> luaL_Reg)

Example usage:
  wrk2 -t4 -c100 -d30s -R1000 -p 50,95,99 -o result.json http://localhost/
The only function used from this header was __builtin_clzll, which is
a compiler builtin available on all architectures (ARM, x86, etc.),
not an x86 intrinsic. The include was added when hdr_histogram.c was
first vendored in 2014 but was never actually needed.
When using -o - to output JSON to stdout, redirect the "Running test"
and "Thread calibration" messages to stderr so that stdout contains
only valid JSON. This allows piping directly to jq and other tools.
- Add url field to identify tested endpoint
- Add config section with threads, connections, duration, rate
- Add bytes_per_second for transfer rate
- Use full precision (%g) for float values instead of truncated %.2f
- Return error code 1 when output file cannot be opened
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant