-
Notifications
You must be signed in to change notification settings - Fork 120
95 lines (82 loc) · 2.65 KB
/
Copy pathbenchmarks.yml
File metadata and controls
95 lines (82 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: API Benchmarks
on: workflow_dispatch
concurrency:
group: benchmarks-${{ github.ref }}
cancel-in-progress: true
jobs:
benchmark:
name: API performance benchmarks
runs-on: ubuntu-latest
timeout-minutes: 20
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: npm
cache-dependency-path: backend/package-lock.json
- name: Install dependencies
run: npm ci --prefer-offline
- name: Run benchmark suite
run: npm run benchmark
env:
OPENAI_API_KEY: sk-ci-benchmark-placeholder
BENCHMARK_DURATION_SEC: 2
BENCHMARK_WARMUP_SEC: 1
BENCHMARK_CONNECTIONS: 5
- name: Compare against baseline
run: npm run benchmark:compare
- name: Upload benchmark artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: api-benchmarks
path: |
backend/benchmarks/results.json
backend/benchmarks/trend.md
retention-days: 90
- name: Publish benchmark summary
if: always()
run: |
if [ -f benchmarks/results.json ]; then
echo "## Benchmark Results" >> "$GITHUB_STEP_SUMMARY"
node -e "
const r = require('./benchmarks/results.json');
console.log('| Endpoint | p99 (ms) | throughput |');
console.log('|----------|----------|------------|');
for (const e of r.endpoints) {
console.log('| ' + e.name + ' | ' + e.latency.p99.toFixed(2) + ' | ' + e.throughput.toFixed(0) + ' req/s |');
}
" >> "$GITHUB_STEP_SUMMARY"
fi
load-test:
name: Peak traffic simulation
runs-on: ubuntu-latest
timeout-minutes: 15
if: github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/main'
defaults:
run:
working-directory: backend
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: npm
cache-dependency-path: backend/package-lock.json
- name: Install dependencies
run: npm ci --prefer-offline
- name: Peak load on health endpoint
run: |
npx tsx src/tests/benchmarks/serve.ts &
SERVER_PID=$!
sleep 2
npx autocannon -c 50 -d 15 -p 5 http://127.0.0.1:3099/health
kill $SERVER_PID || true
env:
OPENAI_API_KEY: sk-ci-benchmark-placeholder