Skip to content

Commit d64c90b

Browse files
committed
chore: Add benchmark suite and update package-lock
- Add comprehensive benchmark suite (proxy-benchmark.js) - Add Docker benchmark script (docker-benchmark.sh) - Add quick benchmark script (quick-benchmark.sh) - Update package-lock.json for v1.10.0
1 parent 98a6a74 commit d64c90b

File tree

3 files changed

+680
-0
lines changed

3 files changed

+680
-0
lines changed
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "🐳 Docker-based Multi-Protocol Proxy Benchmark Suite"
5+
echo "======================================================"
6+
echo ""
7+
8+
# Configuration
9+
DOCKER_IMAGE="agentic-flow-multi-protocol"
10+
RESULTS_DIR="./benchmark-results"
11+
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
12+
13+
# Create results directory
14+
mkdir -p "$RESULTS_DIR"
15+
16+
echo "📋 Benchmark Configuration:"
17+
echo " - Docker Image: $DOCKER_IMAGE"
18+
echo " - Results Dir: $RESULTS_DIR"
19+
echo " - Timestamp: $TIMESTAMP"
20+
echo ""
21+
22+
# Function to run benchmarks in Docker
23+
run_docker_benchmark() {
24+
local scenario=$1
25+
local env_file=$2
26+
local extra_args=${3:-""}
27+
28+
echo "🔬 Running benchmark: $scenario"
29+
echo " Environment: $env_file"
30+
31+
docker run --rm \
32+
--env-file "$env_file" \
33+
--name "benchmark-$scenario-$$" \
34+
$extra_args \
35+
"$DOCKER_IMAGE" \
36+
> "$RESULTS_DIR/${scenario}_${TIMESTAMP}.log" 2>&1
37+
38+
echo " ✅ Complete: $RESULTS_DIR/${scenario}_${TIMESTAMP}.log"
39+
}
40+
41+
# Scenario 1: Baseline (no security)
42+
echo ""
43+
echo "📊 Scenario 1: Baseline Performance (No Security)"
44+
echo "------------------------------------------------"
45+
cat > /tmp/benchmark-env-1.env << EOF
46+
GOOGLE_GEMINI_API_KEY=test-gemini-key
47+
NODE_ENV=production
48+
LOG_LEVEL=error
49+
EOF
50+
run_docker_benchmark "baseline" "/tmp/benchmark-env-1.env"
51+
52+
# Scenario 2: With authentication
53+
echo ""
54+
echo "📊 Scenario 2: With Authentication"
55+
echo "-----------------------------------"
56+
cat > /tmp/benchmark-env-2.env << EOF
57+
GOOGLE_GEMINI_API_KEY=test-gemini-key
58+
PROXY_API_KEYS=test-key-1,test-key-2,test-key-3
59+
NODE_ENV=production
60+
LOG_LEVEL=error
61+
EOF
62+
run_docker_benchmark "with-auth" "/tmp/benchmark-env-2.env"
63+
64+
# Scenario 3: With rate limiting
65+
echo ""
66+
echo "📊 Scenario 3: With Rate Limiting"
67+
echo "----------------------------------"
68+
cat > /tmp/benchmark-env-3.env << EOF
69+
GOOGLE_GEMINI_API_KEY=test-gemini-key
70+
RATE_LIMIT_POINTS=100
71+
RATE_LIMIT_DURATION=60
72+
NODE_ENV=production
73+
LOG_LEVEL=error
74+
EOF
75+
run_docker_benchmark "with-ratelimit" "/tmp/benchmark-env-3.env"
76+
77+
# Scenario 4: Full security (auth + rate limiting)
78+
echo ""
79+
echo "📊 Scenario 4: Full Security Stack"
80+
echo "-----------------------------------"
81+
cat > /tmp/benchmark-env-4.env << EOF
82+
GOOGLE_GEMINI_API_KEY=test-gemini-key
83+
PROXY_API_KEYS=test-key-1,test-key-2,test-key-3
84+
RATE_LIMIT_POINTS=100
85+
RATE_LIMIT_DURATION=60
86+
NODE_ENV=production
87+
LOG_LEVEL=error
88+
EOF
89+
run_docker_benchmark "full-security" "/tmp/benchmark-env-4.env"
90+
91+
# Scenario 5: Memory-constrained
92+
echo ""
93+
echo "📊 Scenario 5: Memory-Constrained (256MB)"
94+
echo "------------------------------------------"
95+
run_docker_benchmark "memory-constrained" "/tmp/benchmark-env-1.env" "--memory=256m"
96+
97+
# Scenario 6: CPU-constrained
98+
echo ""
99+
echo "📊 Scenario 6: CPU-Constrained (0.5 CPU)"
100+
echo "-----------------------------------------"
101+
run_docker_benchmark "cpu-constrained" "/tmp/benchmark-env-1.env" "--cpus=0.5"
102+
103+
# Generate comparison report
104+
echo ""
105+
echo "📈 Generating Comparison Report..."
106+
cat > "$RESULTS_DIR/comparison_${TIMESTAMP}.md" << 'EOF'
107+
# Multi-Protocol Proxy Benchmark Results
108+
109+
## Test Scenarios
110+
111+
1. **Baseline** - No security features
112+
2. **With Authentication** - API key validation
113+
3. **With Rate Limiting** - 100 req/60s limit
114+
4. **Full Security** - Auth + Rate limiting
115+
5. **Memory-Constrained** - 256MB limit
116+
6. **CPU-Constrained** - 0.5 CPU cores
117+
118+
## Performance Analysis
119+
120+
### Methodology
121+
- Docker-isolated testing environment
122+
- Self-signed TLS certificates
123+
- Gemini API proxy (Anthropic format)
124+
- Multiple payload sizes tested
125+
- Concurrent connection testing
126+
127+
### Metrics Collected
128+
- Average latency (ms)
129+
- P95 latency (ms)
130+
- P99 latency (ms)
131+
- Throughput (req/s)
132+
- Memory usage
133+
- CPU usage
134+
135+
## Results
136+
137+
EOF
138+
139+
# Analyze results
140+
echo " Processing logs..."
141+
for log in "$RESULTS_DIR"/*_${TIMESTAMP}.log; do
142+
scenario=$(basename "$log" | sed "s/_${TIMESTAMP}.log//")
143+
echo "" >> "$RESULTS_DIR/comparison_${TIMESTAMP}.md"
144+
echo "### $scenario" >> "$RESULTS_DIR/comparison_${TIMESTAMP}.md"
145+
echo '```' >> "$RESULTS_DIR/comparison_${TIMESTAMP}.md"
146+
cat "$log" >> "$RESULTS_DIR/comparison_${TIMESTAMP}.md"
147+
echo '```' >> "$RESULTS_DIR/comparison_${TIMESTAMP}.md"
148+
done
149+
150+
echo ""
151+
echo "✅ Benchmark Suite Complete!"
152+
echo ""
153+
echo "📊 Results:"
154+
echo " - Individual logs: $RESULTS_DIR/*_${TIMESTAMP}.log"
155+
echo " - Comparison report: $RESULTS_DIR/comparison_${TIMESTAMP}.md"
156+
echo ""
157+
echo "🔍 Next Steps:"
158+
echo " 1. Review comparison report"
159+
echo " 2. Analyze performance bottlenecks"
160+
echo " 3. Identify optimization opportunities"
161+
echo " 4. Implement improvements"
162+
echo ""

0 commit comments

Comments
 (0)