feat(benchmarks): auto-generate Interpretation/Recommendation and add -report-only flag

generate_report.go:
- buildInterpretation: derives narrative from p99/p50 tail-latency ratio,
  per-action complexity trend (% increase vs discover baseline), concurrency
  scaling efficiency (GOMAXPROCS=1 vs 16), and cache warm/cold delta
- buildRecommendation: identifies the best throughput/cost GOMAXPROCS level
  from scaling efficiency and adds production sizing guidance

run_benchmarks.sh:
- Add -report-only <dir> flag: re-runs parse_results.go + generate_report.go
  against an existing results directory without rerunning benchmarks

REPORT_TEMPLATE.md:
- Replace manual placeholders with __INTERPRETATION__ and __RECOMMENDATION__
  markers filled by the generator
This commit is contained in:
Mayuresh
2026-04-09 22:34:52 +05:30
parent e6accc3f26
commit e0d7e3508f
3 changed files with 229 additions and 4 deletions

View File

@@ -20,7 +20,6 @@ set -euo pipefail
SCRIPT_START=$(date +%s)
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
RESULTS_DIR="$REPO_ROOT/benchmarks/results/$(date +%Y-%m-%d_%H-%M-%S)"
BENCH_PKG="./benchmarks/e2e/..."
BENCH_TIMEOUT="10m"
BENCH_TIME_SERIAL="10s"
@@ -31,6 +30,38 @@ BENCH_COUNT=1 # benchstat uses the 3 serial files for stability
ONIX_VERSION="$(git -C "$REPO_ROOT" describe --tags --abbrev=0 2>/dev/null || echo "dev")"
REPORT_TEMPLATE="$REPO_ROOT/benchmarks/reports/REPORT_TEMPLATE.md"
# ── -report-only <dir>: regenerate report from an existing results directory ──
if [[ "${1:-}" == "-report-only" ]]; then
RESULTS_DIR="${2:-}"
if [[ -z "$RESULTS_DIR" ]]; then
echo "Usage: bash benchmarks/run_benchmarks.sh -report-only <results-dir>"
echo "Example: bash benchmarks/run_benchmarks.sh -report-only benchmarks/results/2026-04-09_10-30-00"
exit 1
fi
if [[ ! -d "$RESULTS_DIR" ]]; then
echo "ERROR: results directory not found: $RESULTS_DIR"
exit 1
fi
echo "=== Regenerating report from existing results ==="
echo "Results dir : $RESULTS_DIR"
echo ""
cd "$REPO_ROOT"
echo "Parsing results to CSV..."
go run "$REPO_ROOT/benchmarks/tools/parse_results.go" \
-dir="$RESULTS_DIR" -out="$RESULTS_DIR" 2>&1 || true
echo ""
echo "Generating benchmark report..."
go run "$REPO_ROOT/benchmarks/tools/generate_report.go" \
-dir="$RESULTS_DIR" \
-template="$REPORT_TEMPLATE" \
-version="$ONIX_VERSION"
echo ""
echo "Done. Report written to: $RESULTS_DIR/BENCHMARK_REPORT.md"
exit 0
fi
RESULTS_DIR="$REPO_ROOT/benchmarks/results/$(date +%Y-%m-%d_%H-%M-%S)"
cd "$REPO_ROOT"
# ── benchstat is declared as a go tool in go.mod; no separate install needed ──