1 #!/usr/bin/env python2.7
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
20 print("Memory consumption not shown because guppy is not installed")
23 if __name__
== '__main__':
24 parser
= argparse
.ArgumentParser(description
=desc
)
28 help='List of optimization record files or directories searched '
29 'for optimization record files.')
35 help='Max job count (defaults to %(default)s, the current CPU count)')
37 '--no-progress-indicator',
41 help='Do not display any indicator of how many YAML files were read.')
42 args
= parser
.parse_args()
44 print_progress
= not args
.no_progress_indicator
46 files
= optrecord
.find_opt_files(*args
.yaml_dirs_or_files
)
48 parser
.error("No *.opt.yaml files found")
51 all_remarks
, file_remarks
, _
= optrecord
.gather_results(
52 files
, args
.jobs
, print_progress
)
56 bypass
= defaultdict(int)
57 byname
= defaultdict(int)
58 for r
in optrecord
.itervalues(all_remarks
):
60 byname
[r
.Pass
+ "/" + r
.Name
] += 1
62 total
= len(all_remarks
)
63 print("{:24s} {:10d}".format("Total number of remarks", total
))
66 print("{:24s} {:10d}".format("Memory per remark",
67 h
.size
/ len(all_remarks
)))
70 print("Top 10 remarks by pass:")
71 for (passname
, count
) in sorted(bypass
.items(), key
=operator
.itemgetter(1),
73 print(" {:30s} {:2.0f}%". format(passname
, count
* 100. / total
))
75 print("\nTop 10 remarks:")
76 for (name
, count
) in sorted(byname
.items(), key
=operator
.itemgetter(1),
78 print(" {:30s} {:2.0f}%". format(name
, count
* 100. / total
))