Skip to content

Commit ed83ab2

Browse files
Copilotmrjf
andauthored
perf-comparison: validate benchmark scripts before counting them
Agent-Logs-Url: https://github.com/githubnext/tsessebe/sessions/2ed75875-aa1e-4694-906a-6fd7dd84e8eb Co-authored-by: mrjf <180956+mrjf@users.noreply.github.com>
1 parent 6012dce commit ed83ab2

1 file changed

Lines changed: 39 additions & 5 deletions

File tree

.autoloop/programs/perf-comparison/program.md

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,50 @@ Do NOT modify:
5050

5151
## Evaluation
5252

53+
The evaluation block runs validity checks **before** counting benchmark pairs.
54+
If any benchmark script is syntactically invalid (or required tooling is
55+
missing), the metric is reported as `null` so the iteration is rejected
56+
rather than silently accepted with broken benchmarks.
57+
5358
```bash
54-
# Set up Python environment if needed
59+
# Set up Python environment if needed.
5560
if ! command -v python3 &>/dev/null; then
56-
echo "Python3 not found, skipping"
61+
echo '{"benchmarked_functions": null, "rejected_reason": "python3 not available"}'
62+
exit 0
5763
fi
5864
pip3 install pandas --quiet 2>/dev/null || true
5965

60-
# Count the number of benchmark pairs (functions with both TS and Python benchmarks)
66+
# Validity: every TypeScript benchmark must transpile cleanly.
67+
# `bun build` parses, type-aware-transpiles, and resolves imports — any of
68+
# those failing means the benchmark would fail at run time. We discard the
69+
# build output; we only care about the exit status.
70+
if command -v bun &>/dev/null; then
71+
for f in benchmarks/tsb/bench_*.ts; do
72+
[ -e "$f" ] || break
73+
if ! bun build "$f" --outdir=/tmp/perf-comparison-bench-check >/dev/null 2>&1; then
74+
echo "{\"benchmarked_functions\": null, \"rejected_reason\": \"invalid TypeScript benchmark: $f\"}"
75+
exit 0
76+
fi
77+
done
78+
else
79+
echo '{"benchmarked_functions": null, "rejected_reason": "bun not available"}'
80+
exit 0
81+
fi
82+
83+
# Validity: every Python benchmark must compile (parse) cleanly.
84+
for f in benchmarks/pandas/bench_*.py; do
85+
[ -e "$f" ] || break
86+
if ! python3 -m py_compile "$f" 2>/dev/null; then
87+
echo "{\"benchmarked_functions\": null, \"rejected_reason\": \"invalid Python benchmark: $f\"}"
88+
exit 0
89+
fi
90+
done
91+
92+
# Count the number of benchmark pairs (functions with both TS and Python benchmarks).
6193
ts_benchmarks=$(ls benchmarks/tsb/bench_*.ts 2>/dev/null | wc -l | tr -d ' ')
6294
py_benchmarks=$(ls benchmarks/pandas/bench_*.py 2>/dev/null | wc -l | tr -d ' ')
6395

64-
# The metric is the minimum of the two (both must exist for a complete benchmark)
96+
# The metric is the minimum of the two (both must exist for a complete benchmark).
6597
if [ "$ts_benchmarks" -lt "$py_benchmarks" ]; then
6698
count=$ts_benchmarks
6799
else
@@ -71,4 +103,6 @@ fi
71103
echo "{\"benchmarked_functions\": ${count:-0}}"
72104
```
73105

74-
The metric is `benchmarked_functions`. **Higher is better.**
106+
The metric is `benchmarked_functions`. **Higher is better.** When validity
107+
checks fail the metric is `null`, which the autoloop runner treats as a
108+
rejected iteration.

0 commit comments

Comments
 (0)