mirror of
https://github.com/python/cpython
synced 2024-09-16 02:59:56 +00:00
Stats: Add summary of top instructions for misses and deferred specialization. (GH-94072)
This commit is contained in:
parent
9a479c3c10
commit
f805d37641
|
@ -188,6 +188,12 @@ def __exit__(*args):
|
||||||
print("</details>")
|
print("</details>")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
def to_str(x):
|
||||||
|
if isinstance(x, int):
|
||||||
|
return format(x, ",d")
|
||||||
|
else:
|
||||||
|
return str(x)
|
||||||
|
|
||||||
def emit_table(header, rows):
|
def emit_table(header, rows):
|
||||||
width = len(header)
|
width = len(header)
|
||||||
header_line = "|"
|
header_line = "|"
|
||||||
|
@ -203,8 +209,8 @@ def emit_table(header, rows):
|
||||||
print(under_line)
|
print(under_line)
|
||||||
for row in rows:
|
for row in rows:
|
||||||
if width is not None and len(row) != width:
|
if width is not None and len(row) != width:
|
||||||
raise ValueError("Wrong number of elements in row '" + str(rows) + "'")
|
raise ValueError("Wrong number of elements in row '" + str(row) + "'")
|
||||||
print("|", " | ".join(str(i) for i in row), "|")
|
print("|", " | ".join(to_str(i) for i in row), "|")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
def emit_execution_counts(opcode_stats, total):
|
def emit_execution_counts(opcode_stats, total):
|
||||||
|
@ -251,6 +257,18 @@ def emit_specialization_overview(opcode_stats, total):
|
||||||
("Not specialized", not_specialized, f"{not_specialized*100/total:0.1f}%"),
|
("Not specialized", not_specialized, f"{not_specialized*100/total:0.1f}%"),
|
||||||
("Specialized", specialized, f"{specialized*100/total:0.1f}%"),
|
("Specialized", specialized, f"{specialized*100/total:0.1f}%"),
|
||||||
))
|
))
|
||||||
|
for title, field in (("Deferred", "specialization.deferred"), ("Misses", "specialization.miss")):
|
||||||
|
total = 0
|
||||||
|
counts = []
|
||||||
|
for i, opcode_stat in enumerate(opcode_stats):
|
||||||
|
value = opcode_stat.get(field, 0)
|
||||||
|
counts.append((value, opname[i]))
|
||||||
|
total += value
|
||||||
|
counts.sort(reverse=True)
|
||||||
|
if total:
|
||||||
|
with Section(f"{title} by instruction", 3):
|
||||||
|
rows = [ (name, count, f"{100*count/total:0.1f}%") for (count, name) in counts[:10] ]
|
||||||
|
emit_table(("Name", "Count:", "Ratio:"), rows)
|
||||||
|
|
||||||
def emit_call_stats(stats):
|
def emit_call_stats(stats):
|
||||||
stats_path = os.path.join(os.path.dirname(__file__), "../../Include/pystats.h")
|
stats_path = os.path.join(os.path.dirname(__file__), "../../Include/pystats.h")
|
||||||
|
|
Loading…
Reference in a new issue