Skip to content

Commit 8faa590

Browse files
committed
ci: ensure migration benchmark runs
1 parent 0ef7093 commit 8faa590

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

.github/workflows/migration-ci.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
"${{ github.event.pull_request.head.sha }}" \
5050
| tee "$RUNNER_TEMP/changed-files.txt"
5151
52-
if grep -Eq '^(\.crane/|cmd/|internal/|pkg/|go\.mod$|go\.sum$|pyproject\.toml$|src/|tests/benchmarks/|tests/unit/test_crane_score\.py$)' "$RUNNER_TEMP/changed-files.txt"; then
52+
if grep -Eq '^(\.crane/|\.github/workflows/migration-ci\.yml$|cmd/|internal/|pkg/|go\.mod$|go\.sum$|pyproject\.toml$|scripts/ci/|src/|tests/benchmarks/|tests/unit/test_crane_score\.py$)' "$RUNNER_TEMP/changed-files.txt"; then
5353
echo "should-run=true" >> "$GITHUB_OUTPUT"
5454
else
5555
echo "should-run=false" >> "$GITHUB_OUTPUT"
@@ -137,11 +137,6 @@ jobs:
137137
- name: Build Go CLI
138138
run: go build -o "$RUNNER_TEMP/apm-go" ./cmd/apm
139139

140-
- name: Run Python performance guards
141-
run: |
142-
uv run pytest tests/benchmarks/test_scaling_guards.py -v
143-
uv run pytest tests/benchmarks -v --tb=short -m benchmark
144-
145140
- name: Run Python-vs-Go CLI benchmark
146141
run: |
147142
python scripts/ci/migration_cli_benchmark.py \
@@ -151,6 +146,9 @@ jobs:
151146
--markdown-out "$RUNNER_TEMP/migration-cli-benchmark.md" \
152147
--max-ratio 5.0
153148
149+
- name: Run Python scaling guards
150+
run: uv run pytest tests/benchmarks/test_scaling_guards.py -v
151+
154152
- name: Add benchmark summary
155153
if: always()
156154
run: |

scripts/ci/migration_cli_benchmark.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def _measure(
6060
label: str,
6161
env: dict[str, str],
6262
) -> dict[str, object]:
63+
base.mkdir(parents=True, exist_ok=True)
6364
samples: list[dict[str, object]] = []
6465
for index in range(repeats):
6566
cwd = _workspace(base, label, index) if mutates_workspace else base
@@ -75,22 +76,33 @@ def _measure(
7576
}
7677

7778

79+
def _speed_label(ratio: float) -> str:
80+
if ratio == 0:
81+
return "n/a"
82+
if ratio < 1:
83+
return f"{1 / ratio:.2f}x faster"
84+
if ratio > 1:
85+
return f"{ratio:.2f}x slower"
86+
return "same"
87+
88+
7889
def _markdown(results: list[dict[str, object]], max_ratio: float) -> str:
7990
lines = [
8091
"## Migration CLI Benchmark",
8192
"",
8293
f"Max allowed Go/Python median ratio: `{max_ratio:.2f}`",
8394
"",
84-
"| Command | Python median | Go median | Go/Python | Return codes |",
85-
"|---|---:|---:|---:|---|",
95+
"| Command | Python median | Go median | Go/Python | Result | Return codes |",
96+
"|---|---:|---:|---:|---|---|",
8697
]
8798
for row in results:
8899
lines.append(
89-
"| {command} | {python:.4f}s | {go:.4f}s | {ratio:.2f}x | {codes} |".format(
100+
"| {command} | {python:.4f}s | {go:.4f}s | {ratio:.2f}x | {result} | {codes} |".format(
90101
command=row["command"],
91102
python=row["python_median_seconds"],
92103
go=row["go_median_seconds"],
93104
ratio=row["ratio"],
105+
result=_speed_label(float(row["ratio"])),
94106
codes=row["returncodes"],
95107
)
96108
)

0 commit comments

Comments
 (0)