Skip to content

gh-100257: summarize_stats: Link failure kinds to GitHub search #100258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions Tools/scripts/summarize_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ def calculate_specialization_failure_kinds(name, family_stats, defines):
for value, index in failures:
if not value:
continue
rows.append((kind_to_text(index, defines, name), value, format_ratio(value, total_failures)))
link = kind_to_link(index, defines, name, "SPEC_FAIL_")
rows.append((link, value, format_ratio(value, total_failures)))
return rows

def print_specialization_stats(name, family_stats, defines):
Expand Down Expand Up @@ -223,17 +224,25 @@ def parse_kinds(spec_src, prefix="SPEC_FAIL"):
def pretty(defname):
return defname.replace("_", " ").lower()

def kind_to_text(kind, defines, opname):
if kind <= 7:
return pretty(defines[kind][0])
def kind_and_pretty_name(kind, defines, opname):
if kind < 7:
orig = defines[kind][0]
return orig, pretty(orig)

if opname.endswith("ATTR"):
opname = "ATTR"
if opname.endswith("SUBSCR"):
elif opname.endswith("SUBSCR"):
opname = "SUBSCR"
for name in defines[kind]:
if name.startswith(opname):
return pretty(name[len(opname)+1:])
return "kind " + str(kind)
return name, pretty(name[len(opname)+1:])

return kind, "kind " + str(kind)

def kind_to_link(kind, defines, opname, sym_name_prefix):
symbol_name, text = kind_and_pretty_name(kind, defines, opname)
search_url = f"https://github.com/search?q=repo%3Apython%2Fcpython%20path:Python/specialize.c%20{sym_name_prefix}{symbol_name}&type=code"
return f"[{text}]({search_url})"

def categorized_counts(opcode_stats):
basic = 0
Expand Down