Skip to content

Commit 79138a1

Browse files
committed
foo
1 parent 2184d77 commit 79138a1

File tree

1 file changed

+63
-45
lines changed

1 file changed

+63
-45
lines changed

.github/workflows/alarm.yml

Lines changed: 63 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,18 @@ jobs:
140140
def fmt_num(v):
141141
if v is None or (isinstance(v,float) and math.isnan(v)): return "—"
142142
try:
143-
if abs(v) >= 1000: return f"{v:,.0f}"
144-
return f"{v:.2f}" if isinstance(v,float) and not v.is_integer() else f"{int(v)}"
143+
if isinstance(v, float) and not v.is_integer():
144+
return f"{v:.2f}"
145+
return f"{int(v):,}"
145146
except Exception:
146147
return str(v)
147148
148149
def fmt_pct(v, highlight=False):
149-
if v is None: return "—"
150+
if v is None or (isinstance(v,float) and math.isnan(v)): return "—"
150151
s = f"{v:+.2f}%"
151152
return f"**{s}**" if highlight else s
152153
153-
# ----- read run params -----
154+
# ----- thresholds -----
154155
tol_rt = float(os.environ.get("RUNTIME_REGRESSION_TOLERANCE_PCT","10"))
155156
tol_ct = float(os.environ.get("COMPILE_REGRESSION_TOLERANCE_PCT","10"))
156157
MAX_REVISIONS = int(os.environ.get("MAX_REVISIONS","5"))
@@ -159,7 +160,6 @@ jobs:
159160
# ----- load artifact (current results) -----
160161
artifacts_path = os.path.abspath(os.environ.get("ARTIFACTS_DIR", "./artifacts"))
161162
if not os.path.exists(artifacts_path):
162-
# no data → no comment/check body
163163
open(os.environ.get("PR_COMMENT_PATH","pr_comment.md"),"w").close()
164164
open(os.environ.get("CHECK_BODY_PATH","check_output.md"),"w").close()
165165
sys.exit(0)
@@ -238,57 +238,75 @@ jobs:
238238
vals.append(float(v))
239239
return stats.mean(vals) if vals else None
240240
241-
# ----- build table rows for ALL benchmarks -----
242-
rows = []
241+
# ----- build TWO tables -----
242+
rows_rt = []
243+
rows_ct = []
243244
reg_found = False
244245
for bid in sorted(current_bm.keys()):
245-
cur_rt = current_bm[bid].get("runtime_fps")
246-
cur_ct = current_bm[bid].get("compile_time")
246+
cur_rt = 0 #current_bm[bid].get("runtime_fps")
247+
cur_ct = 0 #current_bm[bid].get("compile_time")
247248
base_rt = mean_of("runtime_fps", bid)
248249
base_ct = mean_of("compile_time", bid)
249250
250251
d_rt = ((cur_rt - base_rt)/base_rt*100.0) if (base_rt and isinstance(cur_rt,(int,float))) else None
251252
d_ct = ((cur_ct - base_ct)/base_ct*100.0) if (base_ct and isinstance(cur_ct,(int,float))) else None
252253
253-
is_reg = (d_rt is not None and d_rt < -tol_rt) or (d_ct is not None and d_ct > tol_ct)
254-
reg_found = reg_found or is_reg
254+
is_rt_reg = (d_rt is not None and d_rt < -tol_rt)
255+
is_ct_reg = (d_ct is not None and d_ct > tol_ct)
256+
reg_found = reg_found or is_rt_reg or is_ct_reg
255257
256-
stat = "🔴" if is_reg else "✅"
257-
delta_rt_cell = fmt_pct(d_rt, highlight=is_reg and d_rt is not None and d_rt < -tol_rt)
258-
delta_ct_cell = fmt_pct(d_ct, highlight=is_reg and d_ct is not None and d_ct > tol_ct)
258+
stat_rt = "🔴" if is_rt_reg else ("ℹ️" if base_rt is None else "✅")
259+
stat_ct = "🔴" if is_ct_reg else ("ℹ️" if base_ct is None else "✅")
259260
260-
rows.append([
261-
stat,
262-
f"`{bid}`",
263-
fmt_num(cur_rt), fmt_num(base_rt), delta_rt_cell,
264-
fmt_num(cur_ct), fmt_num(base_ct), delta_ct_cell
261+
rows_rt.append([
262+
stat_rt, f"`{bid}`",
263+
fmt_num(cur_rt), fmt_num(base_rt),
264+
fmt_pct(d_rt, highlight=is_rt_reg)
265+
])
266+
rows_ct.append([
267+
stat_ct, f"`{bid}`",
268+
fmt_num(cur_ct), fmt_num(base_ct),
269+
fmt_pct(d_ct, highlight=is_ct_reg)
265270
])
266271
267-
# ----- compose CHECK body -----
268-
header = [
269-
"| status | benchmark_id | current FPS | baseline FPS | Δ FPS | current compile | baseline compile | Δ compile |",
270-
"|:------:|:-------------|-----------:|-------------:|------:|----------------:|-----------------:|---------:|",
272+
header_rt = [
273+
"| status | benchmark_id | current FPS | baseline FPS | Δ FPS |",
274+
"|:------:|:-------------|-----------:|-------------:|------:|",
271275
]
272-
table_lines = header + ["| "+" | ".join(r)+" |" for r in rows]
273-
274-
summary_top = []
275-
summary_top.append(f"Baselines considered: **{len(rev_order)}** commits")
276+
header_ct = [
277+
"| status | benchmark_id | current compile | baseline compile | Δ compile |",
278+
"|:------:|:-------------|----------------:|-----------------:|---------:|",
279+
]
280+
table_rt = header_rt + ["| " + " | ".join(r) + " |" for r in rows_rt]
281+
table_ct = header_ct + ["| " + " | ".join(r) + " |" for r in rows_ct]
282+
283+
# ----- baseline commit list -----
284+
blist = [f"- Commit {i}: {sha}" for i, sha in enumerate(rev_order, 1)]
285+
baseline_block = ["**Baselines considered:** " + f"**{len(rev_order)}** commits"] + blist
286+
287+
# ----- CHECK body (always) -----
288+
check_parts = []
289+
check_parts += baseline_block
290+
check_parts += ["", f"Thresholds: runtime ≤ −{tol_rt:.0f}%, compile ≥ +{tol_ct:.0f}%", ""]
291+
check_parts += ["### Runtime FPS", *table_rt, ""]
292+
check_parts += ["### Compile Time", *table_ct, ""]
293+
check_body = "\n".join(check_parts)
294+
295+
# ----- COMMENT body (only if regressions) -----
276296
if reg_found:
277-
summary_top.append(f"Regressions detected (runtime ≤ −{tol_rt:.0f}%, compile ≥ +{tol_ct:.0f}%).")
278-
else:
279-
summary_top.append("No regressions detected.")
280-
281-
check_body = "\n".join(summary_top + ["", "<details><summary>Benchmark details</summary>", "", *table_lines, "", "</details>"])
282-
283-
# ----- compose COMMENT body -----
284-
if True: #reg_found:
285-
comment_body = "\n".join([
286-
":warning: **Benchmark comparison vs W&B baselines**",
287-
f"- Baselines considered: **{len(rev_order)}** commits",
288-
f"- Thresholds: runtime ≤ −{tol_rt:.0f}%, compile ≥ +{tol_ct:.0f}%",
297+
comment_parts = [
298+
":warning: **Benchmark Regression Detected**",
299+
*baseline_block,
289300
"",
290-
*table_lines
291-
])
301+
f"Thresholds: runtime ≤ −{tol_rt:.0f}%, compile ≥ +{tol_ct:.0f}%",
302+
"",
303+
"### Runtime FPS",
304+
*table_rt,
305+
"",
306+
"### Compile Time",
307+
*table_ct,
308+
]
309+
comment_body = "\n".join(comment_parts)
292310
else:
293311
comment_body = ""
294312
@@ -321,7 +339,7 @@ jobs:
321339
echo "SCRIPT_OUTPUT=" >> "$GITHUB_ENV"
322340
fi
323341
324-
- name: Add PR comment (only if regressions)
342+
- name: Add PR comment
325343
if: ${{ steps.pr.outputs.pr_number != '' && env.SCRIPT_OUTPUT != '' }}
326344
uses: actions/github-script@v7
327345
env:
@@ -336,7 +354,7 @@ jobs:
336354
body: process.env.COMMENT_BODY
337355
});
338356
339-
- name: Publish PR check (always show full table)
357+
- name: Publish PR check
340358
if: always()
341359
uses: actions/github-script@v7
342360
env:
@@ -349,8 +367,8 @@ jobs:
349367
const hasRegs = (process.env.HAS_REGRESSIONS || 'false').trim() === 'true';
350368
const conclusion = 'success';
351369
const summary = hasRegs
352-
? 'Regressions detected. See the table below.'
353-
: 'No regressions detected. See the table below.';
370+
? '🔴 Regressions detected. See tables below.'
371+
: 'No regressions detected. See tables below.';
354372
await github.rest.checks.create({
355373
owner: context.repo.owner,
356374
repo: context.repo.repo,

0 commit comments

Comments
 (0)