Skip to content

Add API benchmark toolkit - #2

Merged
viqueen merged 16 commits into
mainfrom
feature/benchmark-tooling
Mar 6, 2026
Merged

Add API benchmark toolkit#2
viqueen merged 16 commits into
mainfrom
feature/benchmark-tooling

Conversation

@viqueen

@viqueen viqueen commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a Node.js CLI toolkit under toolkit/ for benchmarking Docker Compose-based API services
  • Captures build time, deploy/start time, and k6 load test metrics (throughput, latency percentiles, error rate)
  • Publishes results to Grafana Cloud via OTLP/HTTP for cross-implementation comparison
  • Includes comparison reporting with terminal table output and best-value highlighting
  • Uses npm workspaces so everything installs and runs from the repo root

Commands

Command Description
npm run benchmark -- run <target> Full pipeline: build, deploy, loadtest, collect
npm run benchmark -- build <target> Docker compose build + timing
npm run benchmark -- deploy <target> Docker compose up + readiness wait + timing
npm run benchmark -- loadtest <target> k6 load test against running target
npm run benchmark -- publish <results> Push results to Grafana Cloud
npm run benchmark -- compare <files...> Compare results in terminal table
npm run benchmark -- list List configured targets
npm run benchmark -- clean <target> Docker compose down

Test plan

  • Run npm install from repo root
  • Run npm run benchmark -- list to verify config loading
  • Run npm run benchmark -- --help to verify all commands registered
  • Add a sample Docker Compose project and run full pipeline
  • Verify results JSON is written to results/
  • Configure Grafana Cloud credentials and test --publish
  • Run compare with multiple result files

🤖 Generated with Claude Code

viqueen and others added 9 commits March 4, 2026 13:24
Sets up the benchmark toolkit under toolkit/ with commander-based CLI,
stub commands (build, deploy, loadtest, run, publish, compare, list, clean),
and core utilities (timer, logger, exec wrapper).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Zod-based config validation with env var interpolation,
target resolution, and a working list command to display
configured benchmark targets.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Docker Compose wrapper (build, up, down, ps), HTTP-based health
check polling for readiness detection, and wired-up build/deploy/clean
commands with high-resolution timing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
k6 subprocess wrapper, summary JSON parser for extracting latency
percentiles and throughput metrics, bundled default HTTP and gRPC
k6 scripts, and wired-up loadtest command with VU/duration overrides.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Full benchmark pipeline: build -> deploy -> loadtest -> collect -> write.
Environment info collector (OS, arch, CPU, memory, tool versions),
JSON results writer, and run command with skip/override/publish options.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
OTLP JSON formatter converting benchmark results to OpenTelemetry
metric format, Grafana Cloud publisher with Basic auth and retry
logic, and publish command for pushing result files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Load multiple result JSON files, compare metrics side-by-side
with best-value highlighting (green), and render a formatted
terminal table using cli-table3 and chalk.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Covers prerequisites, setup, quick start, all CLI commands with
options and examples, config reference, metrics captured, Grafana
Cloud publishing, custom k6 scripts, and project structure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds toolkit as an npm workspace so `npm install` at the root
installs everything. Adds `npm run benchmark` script so the CLI
can be invoked without navigating into toolkit/. Updates README
to reflect the simpler workflow.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 4, 2026 03:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Node.js-based benchmarking toolkit to this repo for running a Docker Compose build/deploy pipeline, executing k6 load tests, writing results to JSON, comparing runs in the terminal, and optionally publishing metrics to Grafana Cloud via OTLP/HTTP.

Changes:

  • Introduces toolkit/ as an npm workspace providing a benchmark CLI with commands for build/deploy/loadtest/run/publish/compare/list/clean.
  • Implements metrics collection/parsing plus reporting (JSON output + terminal comparison table).
  • Adds Grafana Cloud OTLP/HTTP publishing and updates repo docs/config to support running benchmarks from the root.

Reviewed changes

Copilot reviewed 31 out of 35 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
toolkit/src/util/logger.js Adds pino-based pretty logger helper.
toolkit/src/util/exec.js Adds execa wrapper with debug logging.
toolkit/src/report/table.js Renders terminal comparison tables with best-value highlighting.
toolkit/src/report/json.js Writes benchmark results JSON files to disk.
toolkit/src/report/compare.js Loads result files and computes “best” values for comparison.
toolkit/src/publish/grafana-cloud.js Publishes metrics to Grafana Cloud via OTLP/HTTP with retry logic.
toolkit/src/publish/formatter.js Formats results into OTLP/HTTP JSON metric payloads.
toolkit/src/metrics/k6-parser.js Parses k6 summary-export JSON into normalized metrics.
toolkit/src/metrics/collector.js Collects environment metadata and assembles final results object.
toolkit/src/core/timer.js Provides high-resolution timing utility.
toolkit/src/core/k6.js Runs k6 with --summary-export and returns parsed output.
toolkit/src/core/health.js Polls readiness probe endpoint until healthy/timeout.
toolkit/src/core/docker.js Wraps docker compose build/up/down/ps execution.
toolkit/src/config/schema.js Defines Zod schema for benchmark config.
toolkit/src/config/loader.js Loads, interpolates env vars, validates, and resolves targets.
toolkit/src/config/defaults.js Adds defaults object (currently not integrated elsewhere).
toolkit/src/cli/index.js Defines top-level CLI program and global options.
toolkit/src/cli/commands/run.js Implements full pipeline command (build → deploy → loadtest → collect → cleanup).
toolkit/src/cli/commands/publish.js Implements publish command for existing results JSON.
toolkit/src/cli/commands/loadtest.js Implements loadtest-only command against a running target.
toolkit/src/cli/commands/list.js Lists configured benchmark targets.
toolkit/src/cli/commands/deploy.js Implements deploy timing + readiness wait.
toolkit/src/cli/commands/compare.js Implements comparison of multiple results files.
toolkit/src/cli/commands/clean.js Implements docker compose down teardown command.
toolkit/src/cli/commands/build.js Implements build timing command.
toolkit/package.json Declares toolkit workspace package, deps, and benchmark bin.
toolkit/package-lock.json Locks toolkit dependencies.
toolkit/k6/scripts/default-http.js Adds default HTTP k6 script.
toolkit/k6/scripts/default-grpc.js Adds default gRPC k6 script.
toolkit/bin/benchmark.js Adds CLI entrypoint script.
package.json Adds npm workspaces and root benchmark script.
package-lock.json Updates lockfile for workspace linkage and deps.
benchmark.config.json Adds example benchmark configuration and Grafana env interpolation.
README.md Adds full documentation and usage instructions for toolkit.
.gitignore Ignores results/ output directory.
Files not reviewed (1)
  • toolkit/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread toolkit/src/config/schema.js Outdated
Comment thread toolkit/src/config/schema.js Outdated
Comment thread toolkit/src/core/k6.js Outdated
Comment thread toolkit/src/util/logger.js
Comment thread toolkit/src/report/table.js
Comment thread toolkit/package.json Outdated
Comment thread toolkit/src/cli/index.js Outdated
Comment thread toolkit/src/cli/commands/run.js Outdated
Comment thread toolkit/src/report/table.js Outdated
Comment thread toolkit/src/config/defaults.js Outdated
viqueen and others added 7 commits March 4, 2026 16:23
- Fix default k6 script path to toolkit/k6/scripts/default-http.js
- Make readinessProbe httpGet.port optional (falls back to target port)
- Clean up k6 temp summary file after parsing
- Fix pino-pretty translateTime format (HH:mm:ss not HH:MM:ss)
- Multiply error rate by 100 for Error % column display
- Remove redundant lowerIsBetter branches in highlight()
- Merge config defaults into targets in resolveTarget()
- Remove unused ora dependency
- Remove unused defaults.js (Zod schema handles defaults)
- Drop --output CLI default so config output.dir is respected
- Guard cleanup in run command to avoid masking errors

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Configures ESLint (flat config) with eslint-config-prettier and
Prettier with singleQuote, trailingComma, 100 printWidth. Adds
lint, lint:fix, format, and format:check npm scripts. Fixes all
lint errors and formats all source files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Moves ESLint and Prettier config, dependencies, and scripts into
the toolkit workspace. Root scripts now delegate to workspaces
via --workspaces --if-present, so future workspaces can define
their own lint/format/build scripts independently.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@viqueen
viqueen merged commit fe4a5fe into main Mar 6, 2026
1 check passed
@viqueen
viqueen deleted the feature/benchmark-tooling branch March 6, 2026 01:36
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.

2 participants