GC-301h · Module 3
Performance Benchmarks & Deployment Triggers
3 min read
Performance benchmarks powered by Gemini CLI analyze code changes for performance implications before deployment. The pattern: run the benchmark suite, pipe results to Gemini for regression analysis, and gate deployment on the findings. Gemini is not measuring performance — your benchmark suite does that — but it is interpreting the results. A 15% increase in p95 latency might be acceptable if the PR adds encryption, or alarming if the PR adds a minor UI feature. Gemini provides the contextual judgment that raw numbers cannot.
Deployment triggers close the loop from code change to production. After all quality gates pass — tests, security scan, performance benchmarks, Gemini review — the CI pipeline can automatically trigger deployment to staging or production. The Gemini analysis adds a layer of AI judgment: "Based on the scope and risk of these changes, recommend deployment to staging for manual verification" or "Low-risk documentation changes — safe for direct production deployment." This is advisory automation — it recommends rather than decides, keeping humans in the deployment loop.
#!/bin/bash
# Performance benchmark analysis + deployment trigger
set -euo pipefail
# Run benchmarks
npm run benchmark -- --json > bench-results.json
# Get Gemini analysis of benchmark results
DIFF=$(git diff origin/main...HEAD)
ANALYSIS=$(gemini -p "Analyze these benchmark results in the context of the code changes. Identify performance regressions, their likely cause, and whether they are acceptable. Output JSON: {regressions: [{metric, change_pct, cause, acceptable: boolean}], deploy_recommendation: \"production\"|\"staging\"|\"block\", reasoning: string}\n\nBenchmarks:\n$(cat bench-results.json)\n\nCode changes:\n$DIFF" \
--output-format json 2>/dev/null)
RECOMMENDATION=$(echo "$ANALYSIS" | jq -r '.response.deploy_recommendation')
REASONING=$(echo "$ANALYSIS" | jq -r '.response.reasoning')
case "$RECOMMENDATION" in
production)
echo "::notice::Deploy to production — $REASONING"
gh workflow run deploy.yml -f environment=production
;;
staging)
echo "::warning::Deploy to staging for verification — $REASONING"
gh workflow run deploy.yml -f environment=staging
;;
block)
echo "::error::Deployment blocked — $REASONING"
exit 1
;;
esac