-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathbenchmark.sh
More file actions
executable file
·73 lines (56 loc) · 1.95 KB
/
benchmark.sh
File metadata and controls
executable file
·73 lines (56 loc) · 1.95 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
#!/bin/bash
# Performance benchmarking script for VacciChain
# Usage: ./benchmark.sh [backend|contract|all]
set -e
BENCHMARK_TYPE=${1:-all}
RESULTS_DIR="benchmark-results"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
mkdir -p "$RESULTS_DIR"
echo "🚀 Starting VacciChain performance benchmarks..."
# Backend benchmarks
if [ "$BENCHMARK_TYPE" = "backend" ] || [ "$BENCHMARK_TYPE" = "all" ]; then
echo ""
echo "📊 Backend API Benchmarks"
echo "========================"
if ! command -v autocannon &> /dev/null; then
echo "Installing autocannon..."
npm install -g autocannon
fi
# Check if backend is running
if ! curl -s http://localhost:4000/health > /dev/null; then
echo "❌ Backend not running on port 4000"
echo "Start it with: cd backend && npm run dev"
exit 1
fi
echo "Benchmarking /health endpoint..."
autocannon -c 10 -d 30 -p 10 http://localhost:4000/health \
> "$RESULTS_DIR/health_${TIMESTAMP}.txt"
echo "Benchmarking /verify endpoint..."
autocannon -c 10 -d 30 -p 10 \
-H "Content-Type: application/json" \
http://localhost:4000/verify/GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSC4 \
> "$RESULTS_DIR/verify_${TIMESTAMP}.txt"
echo "✅ Backend benchmarks complete"
echo "Results saved to $RESULTS_DIR/"
fi
# Contract gas benchmarks
if [ "$BENCHMARK_TYPE" = "contract" ] || [ "$BENCHMARK_TYPE" = "all" ]; then
echo ""
echo "📊 Contract Gas Usage Benchmarks"
echo "================================"
cd contracts
echo "Building contract..."
make build > /dev/null
echo "Running gas benchmarks..."
cargo test --release -- --nocapture --test-threads=1 2>&1 | tee "../$RESULTS_DIR/gas_${TIMESTAMP}.txt"
echo "✅ Contract benchmarks complete"
cd ..
fi
echo ""
echo "📈 Benchmark Summary"
echo "==================="
echo "Results saved to: $RESULTS_DIR/"
echo ""
echo "To compare with baseline:"
echo " git show origin/main:backend/benchmarks/health-benchmark.txt"
echo ""