|
12 | 12 | # SPDX-FileCopyrightText: Copyright the Vortex contributors |
13 | 13 |
|
14 | 14 | import math |
| 15 | +import os |
15 | 16 | import re |
16 | 17 | import sys |
17 | 18 | from dataclasses import dataclass |
@@ -763,6 +764,27 @@ def format_within_engine_summary(analyses: dict[str, dict[str, Any]]) -> str | N |
763 | 764 | return " · ".join(summaries) |
764 | 765 |
|
765 | 766 |
|
| 767 | +def format_title(benchmark_name: str, pr: pd.DataFrame) -> str: |
| 768 | + """Render the comment title, linking the suite explainer doc emitted by the benchmark binary. |
| 769 | +
|
| 770 | + The doc path is a repo-relative markdown path carried on the PR result rows (the `doc` |
| 771 | + field, populated from `Benchmark::doc_path` in Rust), so the benchmark code is the single |
| 772 | + source of truth for where each suite is documented. The link pins the PR's own commit so |
| 773 | + it resolves before the PR merges and stays valid afterwards. |
| 774 | + """ |
| 775 | + |
| 776 | + title = f"# Benchmarks: {benchmark_name}" if benchmark_name else "# Benchmarks" |
| 777 | + if "doc" in pr.columns: |
| 778 | + docs = pr["doc"].dropna().unique() |
| 779 | + if len(docs) > 0: |
| 780 | + server_url = os.environ.get("GITHUB_SERVER_URL", "https://github.com") |
| 781 | + repository = os.environ.get("GITHUB_REPOSITORY", "vortex-data/vortex") |
| 782 | + commits = pr["commit_id"].dropna().unique() if "commit_id" in pr.columns else [] |
| 783 | + ref = commits[0] if len(commits) > 0 else "develop" |
| 784 | + title += f" [\N{OPEN BOOK}]({server_url}/{repository}/blob/{ref}/{docs[0]})" |
| 785 | + return title |
| 786 | + |
| 787 | + |
766 | 788 | def format_report_help() -> str: |
767 | 789 | """Render explanatory markdown for the benchmark report headline fields.""" |
768 | 790 |
|
@@ -823,6 +845,7 @@ def main() -> None: |
823 | 845 | benchmark_name = sys.argv[3] if len(sys.argv) > 3 else "" |
824 | 846 |
|
825 | 847 | pr = pd.read_json(sys.argv[2], lines=True) |
| 848 | + title = format_title(benchmark_name, pr) |
826 | 849 | base = read_latest_baseline_rows(sys.argv[1], pr) |
827 | 850 |
|
828 | 851 | base_commit_id = set(base["commit_id"].unique()) |
@@ -896,6 +919,8 @@ def main() -> None: |
896 | 919 | shifts += f" · Median polish {format_ratio_change(float(np.exp(polish.overall)))}" |
897 | 920 | summary_fields.append(f"**Shifts**: {shifts}") |
898 | 921 |
|
| 922 | + print(title) |
| 923 | + print("") |
899 | 924 | print("<br>".join(summary_fields)) |
900 | 925 | print("") |
901 | 926 | print(format_report_help()) |
|
0 commit comments