Skip to content

Commit b92fb4d

Browse files
authored
Merge pull request #149 from faster-cpython/better-tables
Improve legibility of navigation tables
2 parents 6f324e7 + db01d23 commit b92fb4d

File tree

7 files changed

+47
-69
lines changed

7 files changed

+47
-69
lines changed

Diff for: bench_runner/result.py

+5-18
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,11 @@ def geometric_mean(self) -> str:
119119

120120
lines = self.contents_lines
121121

122-
if (
123-
self.head.benchmark_hash is None
124-
or self.ref.benchmark_hash != self.head.benchmark_hash
125-
):
126-
suffix = r" \*"
127-
else:
128-
suffix = ""
129-
130122
# We want to get the *last* geometric mean in the file, in case
131123
# it's divided by tags
132124
for line in lines[::-1]:
133125
if "Geometric mean" in line:
134-
geometric_mean = line.split("|")[3].strip() + suffix
126+
geometric_mean = line.split("|")[3].strip()
135127
break
136128
else:
137129
geometric_mean = "not sig"
@@ -224,13 +216,8 @@ def summary(self) -> str:
224216
return ""
225217

226218
result = self.geometric_mean
227-
reliability = self.hpt_reliability
228-
if reliability is not None:
229-
reliability = reliability[:-4]
230-
result += f" ({reliability}%)"
231-
memory_change = self.memory_change
232-
if memory_change not in (None, "unknown"):
233-
result += f" ({memory_change} m)"
219+
result = result.replace("faster", "↑")
220+
result = result.replace("slower", "↓")
234221

235222
return result
236223

@@ -626,9 +613,9 @@ def hash_and_flags(self) -> str:
626613
# A representation for the user that combines the commit hash and other flags
627614
parts = [self.cpython_hash]
628615
if self.is_tier2:
629-
parts.append("2️⃣")
616+
parts.append("️(T2)")
630617
if self.is_jit:
631-
parts.append("*️⃣")
618+
parts.append("(JIT)")
632619
return " ".join(parts)
633620

634621
@functools.cached_property

Diff for: bench_runner/scripts/compare.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ def compare_pair(
6565
("slower", "faster"),
6666
)
6767

68-
return f"{comparison.summary} [table]({name}.md) [plot]({name}.png)"
68+
return (
69+
comparison.summary
70+
+ f" [{util.TYPE_TO_ICON['table']}]({name}.md)"
71+
+ f" [{util.TYPE_TO_ICON['time plot']}]({name}.png)"
72+
)
6973

7074

7175
def write_row(fd, columns: list[str]):

Diff for: bench_runner/scripts/generate_results.py

+24-11
Original file line numberDiff line numberDiff line change
@@ -164,22 +164,35 @@ def output_results_index(
164164
"""
165165
bases = [*bases, "base"]
166166

167-
head = ["date", "fork", "ref", "version", "hash"] + [
168-
f"vs. {base}:" for base in bases
169-
]
167+
head = ["date", "fork/ref", "hash/flags"] + [f"vs. {base}:" for base in bases]
170168

171169
rows = []
172170
for result in results:
173171
versus = []
174172
for base in bases:
175173
if base in result.bases and result.bases[base].valid_comparison:
176-
versus.append(
177-
table.md_link(
178-
result.bases[base].summary,
179-
result.bases[base].filename.with_suffix(".md"),
174+
compare = result.bases[base]
175+
entry = (
176+
compare.summary
177+
+ "<br>"
178+
+ table.md_link(
179+
util.TYPE_TO_ICON["table"],
180+
compare.filename.with_suffix(".md"),
181+
filename,
182+
)
183+
+ table.md_link(
184+
util.TYPE_TO_ICON["time plot"],
185+
compare.filename.with_suffix(".png"),
180186
filename,
181187
)
182188
)
189+
if base == "base" and compare.memory_change not in (None, "unknown"):
190+
entry += table.md_link(
191+
util.TYPE_TO_ICON["memory plot"],
192+
compare.filename.parent / (compare.filename.stem + "-mem.png"),
193+
filename,
194+
)
195+
versus.append(entry)
183196
else:
184197
versus.append("")
185198

@@ -188,9 +201,7 @@ def output_results_index(
188201
table.md_link(
189202
result.commit_date, str(result.filename.parent), filename
190203
),
191-
unquote(result.fork),
192-
result.ref[:10],
193-
result.version,
204+
f"{unquote(result.fork)}/{result.ref}",
194205
result.hash_and_flags,
195206
*versus,
196207
]
@@ -393,7 +404,9 @@ def get_directory_indices_entries(
393404
dirpath,
394405
result.runner,
395406
base,
396-
table.md_link(type, result.filename.name),
407+
table.md_link(
408+
util.TYPE_TO_ICON.get(type, "") + type, result.filename.name
409+
),
397410
)
398411
)
399412

Diff for: bench_runner/util.py

+7
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@ def get_benchmark_hash() -> str:
1515
hash.update(os.environ["PYPERFORMANCE_HASH"].encode("ascii")[:7])
1616
hash.update(os.environ["PYSTON_BENCHMARKS_HASH"].encode("ascii")[:7])
1717
return hash.hexdigest()[:6]
18+
19+
20+
TYPE_TO_ICON = {
21+
"table": "📄",
22+
"time plot": "📈",
23+
"memory plot": "🧠",
24+
}

Diff for: tests/test_compare.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def test_compare_1_to_n(tmp_path, monkeypatch):
3838
3939
| commit | change |
4040
| -- | -- |
41-
| eb0004c (eb0004c) | 1.57x faster (94%) (1.11x m) [table](linux-eb0004c-vs-9d38120.md) [plot](linux-eb0004c-vs-9d38120.png) |
42-
| b0e1f9c (b0e1f9c) | 1.70x faster \\* (94%) (1.21x m) [table](linux-b0e1f9c-vs-9d38120.md) [plot](linux-b0e1f9c-vs-9d38120.png) |
41+
| eb0004c (eb0004c) | 1.57x ↑ [📄](linux-eb0004c-vs-9d38120.md) [📈](linux-eb0004c-vs-9d38120.png) |
42+
| b0e1f9c (b0e1f9c) | 1.70x ↑ [📄](linux-b0e1f9c-vs-9d38120.md) [📈](linux-b0e1f9c-vs-9d38120.png) |
4343
""" # noqa
4444
).strip()
4545
assert expected in content
@@ -72,9 +72,9 @@ def test_compare_n_to_n(tmp_path, monkeypatch):
7272
7373
| | 9d38120 (9d38120) | eb0004c (eb0004c) | b0e1f9c (b0e1f9c) |
7474
| -- | -- | -- | -- |
75-
| 9d38120 | | 1.57x faster (94%) (1.11x m) [table](linux-eb0004c-vs-9d38120.md) [plot](linux-eb0004c-vs-9d38120.png) | 1.70x faster \* (94%) (1.21x m) [table](linux-b0e1f9c-vs-9d38120.md) [plot](linux-b0e1f9c-vs-9d38120.png) |
76-
| eb0004c | 1.57x slower (94%) (0.90x m) [table](linux-9d38120-vs-eb0004c.md) [plot](linux-9d38120-vs-eb0004c.png) | | 1.08x faster \* (94%) (1.09x m) [table](linux-b0e1f9c-vs-eb0004c.md) [plot](linux-b0e1f9c-vs-eb0004c.png) |
77-
| b0e1f9c | 1.70x slower \\* (94%) (0.83x m) [table](linux-9d38120-vs-b0e1f9c.md) [plot](linux-9d38120-vs-b0e1f9c.png) | 1.08x slower \* (94%) (0.92x m) [table](linux-eb0004c-vs-b0e1f9c.md) [plot](linux-eb0004c-vs-b0e1f9c.png) | |
75+
| 9d38120 | | 1.57x ↑ [📄](linux-eb0004c-vs-9d38120.md) [📈](linux-eb0004c-vs-9d38120.png) | 1.70x ↑ [📄](linux-b0e1f9c-vs-9d38120.md) [📈](linux-b0e1f9c-vs-9d38120.png) |
76+
| eb0004c | 1.57x ↓ [📄](linux-9d38120-vs-eb0004c.md) [📈](linux-9d38120-vs-eb0004c.png) | | 1.08x ↑ [📄](linux-b0e1f9c-vs-eb0004c.md) [📈](linux-b0e1f9c-vs-eb0004c.png) |
77+
| b0e1f9c | 1.70x ↓ [📄](linux-9d38120-vs-b0e1f9c.md) [📈](linux-9d38120-vs-b0e1f9c.png) | 1.08x ↓ [📄](linux-eb0004c-vs-b0e1f9c.md) [📈](linux-eb0004c-vs-b0e1f9c.png) | |
7878
""" # noqa
7979
).strip()
8080
assert expected in content

Diff for: tests/test_generate_results.py

-33
Original file line numberDiff line numberDiff line change
@@ -105,39 +105,6 @@ def test_main(tmp_path, monkeypatch):
105105
_run_for_bases(["3.10.4", "3.11.0b3"], repo_path, has_base=["b0e1f9c"])
106106
_run_for_bases(["3.10.4", "3.11.0b3"], repo_path, has_base=["b0e1f9c"])
107107

108-
rows = _parse_table(repo_path / "README.md")
109-
versions = [row[3] for row in rows]
110-
assert len(set(versions)) == len(versions)
111-
print(versions)
112-
assert versions == [
113-
"version",
114-
"---",
115-
"3.12.0a3+",
116-
"3.12.0a2+",
117-
"3.12.0a1+",
118-
"3.11.0b3",
119-
"3.10.4",
120-
]
121-
122-
rows = _parse_table(repo_path / "RESULTS.md")
123-
versions = [row[3] for row in rows]
124-
assert len(set(versions)) != len(versions)
125-
assert versions == [
126-
"version",
127-
"---",
128-
"3.12.0a3+",
129-
"3.12.0a2+",
130-
"3.12.0a1+",
131-
"3.12.0a1+",
132-
"3.11.0b3",
133-
"3.11.0b2",
134-
"3.11.0b1",
135-
"3.11.0a7",
136-
"3.11.0a6",
137-
"3.11.0a3",
138-
"3.10.4",
139-
]
140-
141108

142109
def test_change_bases(tmp_path):
143110
repo_path = _copy_repo(tmp_path)

Diff for: tests/test_result.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def test_merge_base(tmp_path):
7070
assert head.commit_merge_base == "9d38120e335357a3b294277fd5eff0a10e46e043"
7171
assert comparison.ref.version == "3.10.4"
7272
assert comparison.head is head
73-
assert comparison.geometric_mean == "1.70x faster \\*"
73+
assert comparison.geometric_mean == "1.70x faster"
7474

7575

7676
def test_from_scratch(monkeypatch):

0 commit comments

Comments
 (0)