3 # Copyright (C) 2016-2024 Free Software Foundation, Inc.
5 # This file is part of GCC.
7 # GCC is free software; you can redistribute it and/or modify it under
8 # the terms of the GNU General Public License as published by the Free
9 # Software Foundation; either version 3, or (at your option) any later
12 # GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 # You should have received a copy of the GNU General Public License
18 # along with GCC; see the file COPYING3. If not see
19 # <http://www.gnu.org/licenses/>.
27 script_location
= os
.path
.realpath(__file__
)
29 parser
= argparse
.ArgumentParser()
30 parser
.add_argument('location', metavar
= 'dump_file',
31 help = 'Sub-folder with SPEC benchmarks (e.g. Programming/cpu2017/benchspec/CPU)')
32 parser
.add_argument('-s', '--sorting', dest
= 'sorting',
33 choices
= ['branches', 'branch-hitrate', 'hitrate', 'coverage', 'name'],
35 parser
.add_argument('-d', '--def-file', help = 'path to predict.def')
36 parser
.add_argument('-v', '--verbose', action
= 'store_true', help = 'Print verbose informations')
38 args
= parser
.parse_args()
40 benchmarks
= os
.listdir(args
.location
)
42 for b
in sorted(benchmarks
):
44 for root
, dirs
, files
in os
.walk(os
.path
.join(args
.location
, b
)):
46 if x
.endswith('.profile'):
47 dumps
.append(os
.path
.join(root
, x
))
52 temp
= tempfile
.NamedTemporaryFile(delete
= False)
54 temp
.write(open(d
, 'rb').read())
59 print(f
' {b} '.center(160, '='))
61 p
= [os
.path
.join(os
.path
.dirname(script_location
), 'analyze_brprob.py'),
62 temp
.name
, '--sorting', args
.sorting
]
64 p
+= ['-d', args
.def_file
]
68 p
= subprocess
.check_call(p
)