Skip to content

Commit c46dc4c

Browse files
Add API benchmark suite
1 parent 75acf9b commit c46dc4c

8 files changed

Lines changed: 1138 additions & 0 deletions

File tree

benchmarks/.env.benchmark.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
BENCHMARK_TARGET_URL=
2+
BENCHMARK_AUTH_TOKEN=
3+
BENCHMARK_ITERATIONS=20
4+
BENCHMARK_CONCURRENCY=4
5+
BENCHMARK_P99_THRESHOLD_MS=500
6+
BENCHMARK_ERROR_RATE_THRESHOLD=0
7+
JWT_SECRET=development-secret

benchmarks/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# API Benchmarks
2+
3+
Run a reproducible benchmark against the local Express API or an external target.
4+
5+
```bash
6+
npm run benchmark
7+
npm run benchmark:smoke
8+
```
9+
10+
Configuration can be supplied with environment variables. Copy `.env.benchmark.example`
11+
when running outside the default local setup.
12+
13+
- `BENCHMARK_TARGET_URL`: target host. When omitted, the runner starts the local API.
14+
- `BENCHMARK_AUTH_TOKEN`: bearer token for protected routes. When omitted, a local admin token is generated.
15+
- `BENCHMARK_ITERATIONS`: requests per endpoint for the full suite.
16+
- `BENCHMARK_CONCURRENCY`: concurrent workers per endpoint.
17+
- `BENCHMARK_P99_THRESHOLD_MS`: default p99 latency ceiling.
18+
- `BENCHMARK_ERROR_RATE_THRESHOLD`: default allowed error rate percentage.
19+
20+
Results are written to:
21+
22+
- `benchmarks/results/latest.json`
23+
- `benchmarks/results/latest.md`
24+
25+
The smoke mode lowers request volume while still covering every configured endpoint.

0 commit comments

Comments
 (0)