bench-readme.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. RUN_FROM="${RUN_FROM:-1}" # extend an existing pass: RUN_FROM=3 RUNS=3 adds run3 only
  18. TURNS="${CG_TURNS:-3}"
  19. ROWS=(
  20. "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?"
  21. "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?"
  22. "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?"
  23. "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?"
  24. "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?"
  25. "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?"
  26. "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?"
  27. )
  28. echo "### README A/B START $(date) RUNS=$RUN_FROM..$RUNS TURNS=$TURNS"
  29. for row in "${ROWS[@]}"; do
  30. repo="${row%%|*}"; rest="${row#*|}"
  31. # Take the first $TURNS questions and join them with "||" for run-all.sh.
  32. q=""; n=0
  33. while [ "$n" -lt "$TURNS" ] && [ -n "$rest" ]; do
  34. part="${rest%%|*}"
  35. if [ "$rest" = "$part" ]; then rest=""; else rest="${rest#*|}"; fi
  36. [ -n "$q" ] && q="$q||"
  37. q="$q$part"; n=$((n + 1))
  38. done
  39. echo "===== $repo ($n turns) ====="
  40. for run in $(seq "$RUN_FROM" "$RUNS"); do
  41. out="/tmp/ab-readme/$repo/run$run"
  42. mkdir -p "$out"
  43. AGENT_EVAL_OUT="$out" bash "$H/run-all.sh" "$C/$repo" "$q" headless > "$out/console.log" 2>&1
  44. grep -E "^exit [0-9]" "$out/console.log" | sed 's/^/ /' || echo " run$run: (no exit line)"
  45. grep -E "codegraph +[0-9,]+ tok|→ file-access" "$out/console.log" | sed 's/^/ /' || true
  46. done
  47. done
  48. echo "### README A/B DONE $(date)"