3 from __future__
import print_function
5 desc
= """Generate statistics about optimization records from the YAML files
6 generated with -fsave-optimization-record and -fdiagnostics-show-hotness.
8 The tools requires PyYAML and Pygments Python packages."""
13 from collections
import defaultdict
14 from multiprocessing
import cpu_count
, Pool
21 print("Memory consumption not shown because guppy is not installed")
24 if __name__
== "__main__":
25 parser
= argparse
.ArgumentParser(description
=desc
)
29 help="List of optimization record files or directories searched "
30 "for optimization record files.",
37 help="Max job count (defaults to %(default)s, the current CPU count)",
40 "--no-progress-indicator",
44 help="Do not display any indicator of how many YAML files were read.",
46 args
= parser
.parse_args()
48 print_progress
= not args
.no_progress_indicator
50 files
= optrecord
.find_opt_files(*args
.yaml_dirs_or_files
)
52 parser
.error("No *.opt.yaml files found")
55 all_remarks
, file_remarks
, _
= optrecord
.gather_results(
56 files
, args
.jobs
, print_progress
61 bypass
= defaultdict(int)
62 byname
= defaultdict(int)
63 for r
in optrecord
.itervalues(all_remarks
):
65 byname
[r
.Pass
+ "/" + r
.Name
] += 1
67 total
= len(all_remarks
)
68 print("{:24s} {:10d}".format("Total number of remarks", total
))
71 print("{:24s} {:10d}".format("Memory per remark", h
.size
/ len(all_remarks
)))
74 print("Top 10 remarks by pass:")
75 for (passname
, count
) in sorted(
76 bypass
.items(), key
=operator
.itemgetter(1), reverse
=True
78 print(" {:30s} {:2.0f}%".format(passname
, count
* 100.0 / total
))
80 print("\nTop 10 remarks:")
81 for (name
, count
) in sorted(
82 byname
.items(), key
=operator
.itemgetter(1), reverse
=True
84 print(" {:30s} {:2.0f}%".format(name
, count
* 100.0 / total
))