bench-readme.sh 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env bash
  2. # Re-run the README "Benchmark Results" A/B (with vs without codegraph) on the
  3. # current build: the 7 README repos, same queries, RUNS per arm (default 4).
  4. # Output → /tmp/ab-readme/<repo>/run<n>/run-headless-{with,without}[.tN].jsonl
  5. # Aggregate with parse-bench-readme.mjs. Repos must be cloned + indexed under
  6. # $CORPUS (default /tmp/codegraph-corpus) by the build under test.
  7. #
  8. # Each row is a THREE-TURN session: the README question, then two follow-ups
  9. # that stay inside the same flow. Turns 2-3 are where residual context occupancy
  10. # is actually charged — the first answer's tool output is still in the window,
  11. # so the arms diverge on how much headroom each left behind. CG_TURNS=1 runs the
  12. # README question alone (the original single-question A/B).
  13. set -uo pipefail
  14. H="$(cd "$(dirname "$0")" && pwd)"
  15. C="${CORPUS:-/tmp/codegraph-corpus}"
  16. RUNS="${RUNS:-4}"
  17. TURNS="${CG_TURNS:-3}"
  18. ROWS=(
  19. "vscode|How does the extension host communicate with the main process?|Where in that path would a message be dropped if the extension host crashes?|What would I need to change to add a new message type to that protocol?"
  20. "excalidraw|How does Excalidraw render and update canvas elements?|Which part of that path decides whether a full re-render happens or an incremental one?|If I added a new element type, what in that render path would need to change?"
  21. "django|How does Django's ORM build and execute a query from a QuerySet?|Where in that path is the SQL actually compiled into a string?|What would I change to add a new lookup type to that pipeline?"
  22. "tokio|How does tokio schedule and run async tasks on its runtime?|Where does a task move between the local and the global queue in that path?|What in that path would I touch to add a per-task instrumentation hook?"
  23. "okhttp|How does OkHttp process a request through its interceptor chain?|Where in that chain is the connection actually acquired?|What would I change to add a new interceptor stage before the cache?"
  24. "gin|How does gin route requests through its middleware chain?|Where is the 404 / no-route case handled in that same chain?|What would I change to add a per-route middleware that runs before the global ones?"
  25. "alamofire|How does Alamofire build, send, and validate a request?|Where does retry / interceptor logic hook into that path?|What would I change to add a new validation step to it?"
  26. )
  27. echo "### README A/B START $(date) RUNS=$RUNS TURNS=$TURNS"
  28. for row in "${ROWS[@]}"; do
  29. repo="${row%%|*}"; rest="${row#*|}"
  30. # Take the first $TURNS questions and join them with "||" for run-all.sh.
  31. q=""; n=0
  32. while [ "$n" -lt "$TURNS" ] && [ -n "$rest" ]; do
  33. part="${rest%%|*}"
  34. if [ "$rest" = "$part" ]; then rest=""; else rest="${rest#*|}"; fi
  35. [ -n "$q" ] && q="$q||"
  36. q="$q$part"; n=$((n + 1))
  37. done
  38. echo "===== $repo ($n turns) ====="
  39. for run in $(seq 1 "$RUNS"); do
  40. out="/tmp/ab-readme/$repo/run$run"
  41. mkdir -p "$out"
  42. AGENT_EVAL_OUT="$out" bash "$H/run-all.sh" "$C/$repo" "$q" headless > "$out/console.log" 2>&1
  43. grep -E "^exit [0-9]" "$out/console.log" | sed 's/^/ /' || echo " run$run: (no exit line)"
  44. grep -E "codegraph +[0-9,]+ tok|→ file-access" "$out/console.log" | sed 's/^/ /' || true
  45. done
  46. done
  47. echo "### README A/B DONE $(date)"