FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Stats: Add summary of top instructions for misses and deferred specialization. by markshannon · Pull Request #94072 · python/cpython · GitHub

/ cpython Public
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
22 changes: 20 additions & 2 deletions Tools/scripts/summarize_stats.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ def __exit__(*args):
print("</details>")
print()

def to_str(x):
if isinstance(x, int):
return format(x, ",d")
else:
return str(x)

def emit_table(header, rows):
width = len(header)
header_line = "|"
Expand All @@ -203,8 +209,8 @@ def emit_table(header, rows):
print(under_line)
for row in rows:
if width is not None and len(row) != width:
raise ValueError("Wrong number of elements in row '" + str(rows) + "'")
print("|", " | ".join(str(i) for i in row), "|")
raise ValueError("Wrong number of elements in row '" + str(row) + "'")
print("|", " | ".join(to_str(i) for i in row), "|")
print()

def emit_execution_counts(opcode_stats, total):
Expand Down Expand Up @@ -251,6 +257,18 @@ def emit_specialization_overview(opcode_stats, total):
("Not specialized", not_specialized, f"{not_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):
stats_path = os.path.join(os.path.dirname(__file__), "../../Include/pystats.h")
Expand Down

Back | FazBrowse Home | New Git URL