Skip to content

Antigravity - Benchmark APIs#620

Open
lqkhanh295 wants to merge 2 commits into
SecureBananaLabs:mainfrom
lqkhanh295:benchmark-bounty
Open

Antigravity - Benchmark APIs#620
lqkhanh295 wants to merge 2 commits into
SecureBananaLabs:mainfrom
lqkhanh295:benchmark-bounty

Conversation

@lqkhanh295
Copy link
Copy Markdown

Closes #30

Benchmark Results

Target: http://localhost:4000
Connections: 5 | Duration: 2s per endpoint

Endpoint Method Path p50 (ms) p95 (ms) p99 (ms) RPS Error Rate TTFB (ms) Status
Health Check GET /health 1 undefined 3 3206.00 0.00% 1 ✅ PASS
Get Users GET /api/users 1 undefined 3 3174.00 0.00% 1 ✅ PASS
Get Jobs GET /api/jobs 1 undefined 4 3090.00 0.00% 1 ✅ PASS
Search GET /api/search?q=test 0 undefined 2 5169.50 0.00% 1 ✅ PASS
Admin Metrics GET /api/admin/metrics 0 undefined 1 8785.00 0.00% 1 ✅ PASS
Post Job POST /api/jobs 2 undefined 8 1976.50 0.00% 1 ✅ PASS

Copilot AI review requested due to automatic review settings May 22, 2026 12:53
github-actions Bot added a commit that referenced this pull request May 22, 2026
Copy link
Copy Markdown

Copilot AI left a comment

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 baseline benchmarking suite for the API using autocannon, with CI smoke benchmarks and persisted JSON/markdown reports to support regression tracking (Issue #30).

Changes:

  • Adds a root benchmark script plus autocannon/dotenv dev dependencies.
  • Introduces benchmarks/run.mjs + benchmarks/thresholds.json to run/load-gated benchmarks and write results to benchmarks/results/.
  • Adds a GitHub Actions workflow to start the API and run a smoke benchmark on PRs/pushes.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
package.json Adds benchmark script and benchmarking dev dependencies.
package-lock.json Locks new benchmarking dependency tree (autocannon, dotenv, transitive deps).
benchmarks/thresholds.json Defines regression thresholds (p99, error rate, min RPS).
benchmarks/run.mjs Implements benchmark runner, results serialization, and CI gating.
benchmarks/results/summary.md Checks in a sample human-readable benchmark summary.
benchmarks/results/results.json Checks in a sample machine-readable benchmark output.
.github/workflows/benchmark.yml Adds CI job to run a smoke benchmark against a locally started API server.

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

Comment thread benchmarks/run.mjs Outdated
Comment on lines +13 to +16
const HOST = process.env.BENCHMARK_TARGET_HOST || 'http://localhost:3000';
const TOKEN = process.env.BENCHMARK_AUTH_TOKEN || 'test_token';
const DURATION = parseInt(process.env.BENCHMARK_DURATION || '5', 10);
const CONNECTIONS = parseInt(process.env.BENCHMARK_CONNECTIONS || '10', 10);
Comment thread benchmarks/run.mjs
Comment on lines +47 to +49
if (endpoint.auth) {
opts.headers['Authorization'] = `Bearer ${TOKEN}`;
}
Comment thread benchmarks/run.mjs Outdated
Comment on lines +79 to +81
const p50 = result.latency.p50;
const p95 = result.latency.p95;
const p99 = result.latency.p99;
Comment thread benchmarks/run.mjs Outdated
Comment on lines +82 to +85
const rps = result.requests.average;
const errorRate = (result.errors / result.requests.total) * 100 || 0;
// We estimate TTFB by using min latency or a proxy, but autocannon latency is effectively TTFB to full response.
const ttfb = result.latency.min;
Comment thread benchmarks/run.mjs
Comment on lines +91 to +93
p50, p95, p99, rps, errorRate, ttfb,
passed: p99 <= thresholds.maxP99LatencyMs && errorRate <= thresholds.maxErrorRatePercent
};
Comment thread .github/workflows/benchmark.yml Outdated
Comment on lines +25 to +28
run: |
npm run dev -w apps/api &
# Wait for server to start
sleep 5
Comment on lines +34 to +39
run: |
export BENCHMARK_DURATION=2
export BENCHMARK_CONNECTIONS=5
npm run benchmark
env:
CI: true
Comment on lines +6 to +13
| Endpoint | Method | Path | p50 (ms) | p95 (ms) | p99 (ms) | RPS | Error Rate | TTFB (ms) | Status |
|---|---|---|---|---|---|---|---|---|---|
| Health Check | GET | `/health` | 1 | undefined | 3 | 3206.00 | 0.00% | 1 | ✅ PASS |
| Get Users | GET | `/api/users` | 1 | undefined | 3 | 3174.00 | 0.00% | 1 | ✅ PASS |
| Get Jobs | GET | `/api/jobs` | 1 | undefined | 4 | 3090.00 | 0.00% | 1 | ✅ PASS |
| Search | GET | `/api/search?q=test` | 0 | undefined | 2 | 5169.50 | 0.00% | 1 | ✅ PASS |
| Admin Metrics | GET | `/api/admin/metrics` | 0 | undefined | 1 | 8785.00 | 0.00% | 1 | ✅ PASS |
| Post Job | POST | `/api/jobs` | 2 | undefined | 8 | 1976.50 | 0.00% | 1 | ✅ PASS |
Comment on lines +1 to +12
[
{
"name": "Health Check",
"path": "/health",
"method": "GET",
"p50": 1,
"p99": 3,
"rps": 3206,
"errorRate": 0,
"ttfb": 1,
"passed": true
},
Comment thread benchmarks/run.mjs Outdated
Comment on lines +10 to +14
// Load env config
dotenv.config({ path: path.join(__dirname, '.env.benchmark') });

const HOST = process.env.BENCHMARK_TARGET_HOST || 'http://localhost:3000';
const TOKEN = process.env.BENCHMARK_AUTH_TOKEN || 'test_token';
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.

Benchmark APIs with p50, p95, p99 latency, RPS, error rate and TTFB

2 participants