diff options
author | Mark Shannon <mark@hotpy.org> | 2022-05-27 16:31:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-27 16:31:41 +0100 |
commit | bbcf42449e13c0b62f145cd49d12674ef3d5bf64 (patch) | |
tree | 68d3a84f78de47229c46df66eafd4c27474379a7 /Tools/scripts/summarize_stats.py | |
parent | 8995177030c8b41885ad92b260279b7e622ecaea (diff) | |
download | cpython-bbcf42449e13c0b62f145cd49d12674ef3d5bf64.tar.gz cpython-bbcf42449e13c0b62f145cd49d12674ef3d5bf64.zip |
GH-90230: Add stats to breakdown the origin of calls to `PyEval_EvalFrame` (GH-93284)
Diffstat (limited to 'Tools/scripts/summarize_stats.py')
-rw-r--r-- | Tools/scripts/summarize_stats.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Tools/scripts/summarize_stats.py b/Tools/scripts/summarize_stats.py index 3d7479f261b..04d18790f0d 100644 --- a/Tools/scripts/summarize_stats.py +++ b/Tools/scripts/summarize_stats.py @@ -108,13 +108,14 @@ def extract_opcode_stats(stats): opcode_stats[int(n)][rest.strip(".")] = value return opcode_stats -def parse_kinds(spec_src): +def parse_kinds(spec_src, prefix="SPEC_FAIL"): defines = collections.defaultdict(list) + start = "#define " + prefix + "_" for line in spec_src: line = line.strip() - if not line.startswith("#define SPEC_FAIL_"): + if not line.startswith(start): continue - line = line[len("#define SPEC_FAIL_"):] + line = line[len(start):] name, val = line.split() defines[int(val.strip())].append(name.strip()) return defines @@ -129,8 +130,6 @@ def kind_to_text(kind, defines, opname): opname = "ATTR" if opname.endswith("SUBSCR"): opname = "SUBSCR" - if opname.startswith("PRECALL"): - opname = "CALL" for name in defines[kind]: if name.startswith(opname): return pretty(name[len(opname)+1:]) @@ -254,6 +253,9 @@ def emit_specialization_overview(opcode_stats, total): )) def emit_call_stats(stats): + stats_path = os.path.join(os.path.dirname(__file__), "../../Include/pystats.h") + with open(stats_path) as stats_src: + defines = parse_kinds(stats_src, prefix="EVAL_CALL") with Section("Call stats", summary="Inlined calls and frame stats"): total = 0 for key, value in stats.items(): @@ -263,6 +265,11 @@ def emit_call_stats(stats): for key, value in stats.items(): if "Calls to" in key: rows.append((key, value, f"{100*value/total:0.1f}%")) + elif key.startswith("Calls "): + name, index = key[:-1].split("[") + index = int(index) + label = name + " (" + pretty(defines[index][0]) + ")" + rows.append((label, value, f"{100*value/total:0.1f}%")) for key, value in stats.items(): if key.startswith("Frame"): rows.append((key, value, f"{100*value/total:0.1f}%")) |