diff options
author | Mark Shannon <mark@hotpy.org> | 2021-08-04 10:39:52 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-04 10:39:52 (GMT) |
commit | c83919bd635f4433f1c6ae8504996a9fe3c215e5 (patch) | |
tree | 820040d9928408060179d684adc4775f98df76d0 /Tools | |
parent | ac811f9b5a68ce8756911ef2c8be83b46696018f (diff) | |
download | cpython-c83919bd635f4433f1c6ae8504996a9fe3c215e5.zip cpython-c83919bd635f4433f1c6ae8504996a9fe3c215e5.tar.gz cpython-c83919bd635f4433f1c6ae8504996a9fe3c215e5.tar.bz2 |
Add option to write specialization stats to files and script to summarize. (GH-27575)
* Add option to write stats to random file in a directory.
* Add script to summarize stats.
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/scripts/summarize_specialization_stats.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Tools/scripts/summarize_specialization_stats.py b/Tools/scripts/summarize_specialization_stats.py new file mode 100644 index 0000000..1a13ae8 --- /dev/null +++ b/Tools/scripts/summarize_specialization_stats.py @@ -0,0 +1,41 @@ +"""Print a summary of specialization stats for all files in the +default stats folders. +""" + +import collections +import os.path + +if os.name == "nt": + DEFAULT_DIR = "c:\\temp\\py_stats\\" +else: + DEFAULT_DIR = "/tmp/py_stats/" + + +TOTAL = "deferred", "hit", "miss", "unquickened" + +def print_stats(name, family_stats): + total = sum(family_stats[kind] for kind in TOTAL) + if total == 0: + return + print(name+":") + for key in sorted(family_stats): + if not key.startswith("specialization"): + print(f"{key:>12}:{family_stats[key]:>12} {100*family_stats[key]/total:0.1f}%") + for key in ("specialization_success", "specialization_failure"): + print(f" {key}:{family_stats[key]:>12}") + +def main(): + stats = collections.defaultdict(collections.Counter) + for filename in os.listdir(DEFAULT_DIR): + for line in open(os.path.join(DEFAULT_DIR, filename)): + key, value = line.split(":") + key = key.strip() + family, stat = key.split(".") + value = int(value.strip()) + stats[family][stat] += value + + for name in sorted(stats): + print_stats(name, stats[name]) + +if __name__ == "__main__": + main() |