Skip to content

Commit 549a1b2

Browse files
Copilotmrjf
andauthored
Regenerate benchmarks/results.json during Pages build; revert perf-comparison eval to file-count
Agent-Logs-Url: https://github.com/githubnext/tsessebe/sessions/bc8c8dec-26dd-46a4-89e0-62e7f4d245c3 Co-authored-by: mrjf <180956+mrjf@users.noreply.github.com>
1 parent b109ece commit 549a1b2

2 files changed

Lines changed: 22 additions & 56 deletions

File tree

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

Lines changed: 14 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This is an open-ended program — it runs continuously, always adding the next b
2424
- Outputs the same JSON format
2525
5. **Update `playground/benchmarks.html`** if needed to display the new function's comparison metrics.
2626

27-
The evaluation step (below) runs `benchmarks/run_benchmarks.sh` to execute **every** TS/Python benchmark pair and regenerates `benchmarks/results.json` with the real timing data. That regenerated file is what gets committed on a successful iteration, so when the autoloop branch is merged to `main`, the pages workflow (`.github/workflows/pages.yml`) picks up the real results and `playground/benchmarks.html` renders real comparison data instead of "No benchmark data available yet."
27+
The autoloop iteration only needs to add the benchmark scripts; it does **not** need to run them or update `benchmarks/results.json`. The pages workflow (`.github/workflows/pages.yml`) executes `benchmarks/run_benchmarks.sh` on every push to `main` and publishes the regenerated `results.json` to the playground site, so real benchmark data appears on `playground/benchmarks.html` once the autoloop branch is merged.
2828

2929
### Key constraints
3030

@@ -50,58 +50,23 @@ Do NOT modify:
5050

5151
## Evaluation
5252

53-
The evaluation runs `benchmarks/run_benchmarks.sh`, which executes every TS/Python
54-
benchmark pair and writes real timing data to `benchmarks/results.json`. The metric
55-
is the number of benchmarks that appear in that regenerated file — i.e. the number
56-
of function pairs whose benchmarks actually ran to completion and produced valid
57-
JSON output. This means a benchmark pair is only "counted" if it truly runs, and
58-
the committed `benchmarks/results.json` always reflects real data that the
59-
`pages.yml` workflow will copy to the playground on merge to `main`.
60-
6153
```bash
62-
set -euo pipefail
63-
64-
# Ensure Python and pandas are available
54+
# Set up Python environment if needed
6555
if ! command -v python3 &>/dev/null; then
66-
echo "ERROR: python3 is required but not found" >&2
67-
exit 1
68-
fi
69-
python3 -c "import pandas" 2>/dev/null || pip3 install pandas --quiet
70-
71-
# Ensure Bun is available (install if missing — autoloop runners may not have it).
72-
# Failure to install Bun is logged but does not abort the script, because we must
73-
# still emit the final metric line for autoloop to parse.
74-
if ! command -v bun &>/dev/null; then
75-
curl -fsSL https://bun.sh/install | bash || echo "WARN: bun install script failed" >&2
76-
export PATH="$HOME/.bun/bin:$PATH"
77-
fi
78-
if ! command -v bun &>/dev/null; then
79-
echo "ERROR: bun is not available after install attempt; benchmarks will fail" >&2
56+
echo "Python3 not found, skipping"
8057
fi
58+
pip3 install pandas --quiet 2>/dev/null || true
59+
60+
# Count the number of benchmark pairs (functions with both TS and Python benchmarks)
61+
ts_benchmarks=$(ls benchmarks/tsb/bench_*.ts 2>/dev/null | wc -l | tr -d ' ')
62+
py_benchmarks=$(ls benchmarks/pandas/bench_*.py 2>/dev/null | wc -l | tr -d ' ')
8163

82-
# Install JS/TS dependencies so benchmark scripts can import from src/.
83-
# `|| true` keeps the script alive so the final metric is still emitted; any
84-
# errors are visible in the autoloop logs for debugging.
85-
bun install --silent || echo "WARN: bun install failed; benchmarks may fail to import src/" >&2
86-
87-
# Run every benchmark pair and regenerate benchmarks/results.json with real data.
88-
# This is the file .github/workflows/pages.yml copies into the playground, so
89-
# committing it here is what makes real benchmark data appear on the pages site
90-
# once the autoloop branch is merged to main. Output is left visible so
91-
# per-benchmark failures can be diagnosed from autoloop logs; `|| true` ensures
92-
# we still reach the metric emission below if the script exits nonzero.
93-
bash benchmarks/run_benchmarks.sh || echo "WARN: run_benchmarks.sh exited nonzero" >&2
94-
95-
# Metric: number of benchmark entries in the regenerated results.json.
96-
count=$(python3 -c "
97-
import json
98-
try:
99-
with open('benchmarks/results.json') as f:
100-
data = json.load(f)
101-
print(len(data.get('benchmarks', [])))
102-
except Exception:
103-
print(0)
104-
")
64+
# The metric is the minimum of the two (both must exist for a complete benchmark)
65+
if [ "$ts_benchmarks" -lt "$py_benchmarks" ]; then
66+
count=$ts_benchmarks
67+
else
68+
count=$py_benchmarks
69+
fi
10570

10671
echo "{\"benchmarked_functions\": ${count:-0}}"
10772
```

.github/workflows/pages.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ jobs:
3636
- name: Bundle TypeScript compiler for offline playground
3737
run: cp node_modules/typescript/lib/typescript.js ./playground/dist/typescript.js
3838

39-
- name: Copy benchmark results to playground
40-
run: |
41-
mkdir -p ./playground/benchmarks
42-
if [ -f benchmarks/results.json ]; then
43-
cp benchmarks/results.json ./playground/benchmarks/results.json
44-
fi
45-
4639
- name: Setup Python
4740
uses: actions/setup-python@v5
4841
with:
@@ -51,6 +44,14 @@ jobs:
5144
- name: Install Python dependencies
5245
run: pip install pandas numpy
5346

47+
- name: Run benchmarks
48+
run: bash benchmarks/run_benchmarks.sh
49+
50+
- name: Copy benchmark results to playground
51+
run: |
52+
mkdir -p ./playground/benchmarks
53+
cp benchmarks/results.json ./playground/benchmarks/results.json
54+
5455
- name: Validate Python playground examples
5556
run: python scripts/validate-python-examples.py playground/
5657

0 commit comments

Comments
 (0)