-
Notifications
You must be signed in to change notification settings - Fork 92
164 lines (140 loc) · 5.79 KB
/
benchmark.yml
File metadata and controls
164 lines (140 loc) · 5.79 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
name: Performance Benchmarking
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
backend-benchmark:
name: Backend API benchmarks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: npm
cache-dependency-path: backend/package-lock.json
- name: Install dependencies
working-directory: backend
run: npm ci
- name: Start backend server
working-directory: backend
run: |
npm start &
sleep 5
env:
PORT: 4000
STELLAR_NETWORK: testnet
HORIZON_URL: https://horizon-testnet.stellar.org
SOROBAN_RPC_URL: https://soroban-testnet.stellar.org
STELLAR_NETWORK_PASSPHRASE: Test SDF Network ; September 2015
VACCINATIONS_CONTRACT_ID: CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSC4
ADMIN_SECRET_KEY: SBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSC4
ADMIN_PUBLIC_KEY: GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSC4
SEP10_SERVER_KEY: SBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSC4
ISSUER_SECRET_KEY: SBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSC4
JWT_SECRET: test-secret-key-min-32-characters-long
- name: Install autocannon
run: npm install -g autocannon
- name: Benchmark /health endpoint
run: |
autocannon -c 10 -d 30 -p 10 http://localhost:4000/health > health-benchmark.txt
cat health-benchmark.txt
- name: Benchmark /verify endpoint
run: |
autocannon -c 10 -d 30 -p 10 \
-H "Content-Type: application/json" \
http://localhost:4000/verify/GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSC4 > verify-benchmark.txt
cat verify-benchmark.txt
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: backend-benchmarks
path: |
health-benchmark.txt
verify-benchmark.txt
retention-days: 30
contract-gas-benchmark:
name: Contract gas usage benchmarks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust + wasm32 target
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
contracts/target
key: cargo-${{ hashFiles('contracts/Cargo.lock') }}
- name: Build contract
working-directory: contracts
run: make build
- name: Run gas benchmarks
working-directory: contracts
run: |
cargo test --release -- --nocapture --test-threads=1 2>&1 | tee gas-report.txt
grep -E "gas_used|instructions" gas-report.txt > gas-summary.txt || true
- name: Upload gas report
uses: actions/upload-artifact@v4
with:
name: contract-gas-benchmarks
path: |
contracts/gas-report.txt
contracts/gas-summary.txt
retention-days: 30
benchmark-comparison:
name: Compare benchmarks with baseline
runs-on: ubuntu-latest
needs: [backend-benchmark, contract-gas-benchmark]
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download current benchmarks
uses: actions/download-artifact@v4
with:
name: backend-benchmarks
path: current-benchmarks
- name: Download baseline benchmarks
continue-on-error: true
run: |
mkdir -p baseline-benchmarks
git show origin/main:backend/benchmarks/health-benchmark.txt > baseline-benchmarks/health-benchmark.txt 2>/dev/null || echo "No baseline"
git show origin/main:backend/benchmarks/verify-benchmark.txt > baseline-benchmarks/verify-benchmark.txt 2>/dev/null || echo "No baseline"
- name: Compare response times
run: |
echo "## Performance Comparison" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ -f baseline-benchmarks/health-benchmark.txt ]; then
echo "### /health endpoint" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
tail -20 current-benchmarks/health-benchmark.txt >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
fi
if [ -f baseline-benchmarks/verify-benchmark.txt ]; then
echo "### /verify endpoint" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
tail -20 current-benchmarks/verify-benchmark.txt >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
fi
- name: Check for regressions
run: |
# Extract throughput from current benchmarks
CURRENT_HEALTH=$(grep -oP 'Req/Sec.*?\K[\d.]+' current-benchmarks/health-benchmark.txt | head -1 || echo "0")
if [ -f baseline-benchmarks/health-benchmark.txt ]; then
BASELINE_HEALTH=$(grep -oP 'Req/Sec.*?\K[\d.]+' baseline-benchmarks/health-benchmark.txt | head -1 || echo "0")
if (( $(echo "$CURRENT_HEALTH < $BASELINE_HEALTH * 0.8" | bc -l) )); then
echo "⚠️ Performance regression detected on /health endpoint" >> $GITHUB_STEP_SUMMARY
echo "Baseline: $BASELINE_HEALTH req/s, Current: $CURRENT_HEALTH req/s" >> $GITHUB_STEP_SUMMARY
else
echo "✅ No significant performance regression detected" >> $GITHUB_STEP_SUMMARY
fi
fi