Skip to content

Commit f805d37

Browse files
authored
Stats: Add summary of top instructions for misses and deferred specialization. (GH-94072)
1 parent 9a479c3 commit f805d37

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

Tools/scripts/summarize_stats.py

+20-2
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ def __exit__(*args):
188188
print("</details>")
189189
print()
190190

191+
def to_str(x):
192+
if isinstance(x, int):
193+
return format(x, ",d")
194+
else:
195+
return str(x)
196+
191197
def emit_table(header, rows):
192198
width = len(header)
193199
header_line = "|"
@@ -203,8 +209,8 @@ def emit_table(header, rows):
203209
print(under_line)
204210
for row in rows:
205211
if width is not None and len(row) != width:
206-
raise ValueError("Wrong number of elements in row '" + str(rows) + "'")
207-
print("|", " | ".join(str(i) for i in row), "|")
212+
raise ValueError("Wrong number of elements in row '" + str(row) + "'")
213+
print("|", " | ".join(to_str(i) for i in row), "|")
208214
print()
209215

210216
def emit_execution_counts(opcode_stats, total):
@@ -251,6 +257,18 @@ def emit_specialization_overview(opcode_stats, total):
251257
("Not specialized", not_specialized, f"{not_specialized*100/total:0.1f}%"),
252258
("Specialized", specialized, f"{specialized*100/total:0.1f}%"),
253259
))
260+
for title, field in (("Deferred", "specialization.deferred"), ("Misses", "specialization.miss")):
261+
total = 0
262+
counts = []
263+
for i, opcode_stat in enumerate(opcode_stats):
264+
value = opcode_stat.get(field, 0)
265+
counts.append((value, opname[i]))
266+
total += value
267+
counts.sort(reverse=True)
268+
if total:
269+
with Section(f"{title} by instruction", 3):
270+
rows = [ (name, count, f"{100*count/total:0.1f}%") for (count, name) in counts[:10] ]
271+
emit_table(("Name", "Count:", "Ratio:"), rows)
254272

255273
def emit_call_stats(stats):
256274
stats_path = os.path.join(os.path.dirname(__file__), "../../Include/pystats.h")

0 commit comments

Comments
 (0)