-
-
Notifications
You must be signed in to change notification settings - Fork 29.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to write specialization stats to files and script to summa…
…rize. (GH-27575) * Add option to write stats to random file in a directory. * Add script to summarize stats.
- Loading branch information
1 parent
ac811f9
commit c83919b
Showing
4 changed files
with
75 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -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() |