]> git.ipfire.org Git - thirdparty/gcc.git/blame - contrib/analyze_brprob_spec.py
calls: Change return type of predicate function from int to bool
[thirdparty/gcc.git] / contrib / analyze_brprob_spec.py
CommitLineData
fdf3a386
ML
1#!/usr/bin/env python3
2
83ffe9cd 3# Copyright (C) 2016-2023 Free Software Foundation, Inc.
81f86cb9 4#
fdf3a386
ML
5# This file is part of GCC.
6#
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
10# version.
11#
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
15# for more details.
16#
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/>. */
20
21import sys
22import os
23import subprocess
24import tempfile
25import argparse
26
27script_location = os.path.realpath(__file__)
28
29parser = argparse.ArgumentParser()
ca3b6071 30parser.add_argument('location', metavar = 'dump_file',
31ab99f7 31 help = 'Sub-folder with SPEC benchmarks (e.g. Programming/cpu2017/benchspec/CPU)')
ca3b6071
ML
32parser.add_argument('-s', '--sorting', dest = 'sorting',
33 choices = ['branches', 'branch-hitrate', 'hitrate', 'coverage', 'name'],
34 default = 'branches')
59075bc8 35parser.add_argument('-d', '--def-file', help = 'path to predict.def')
e1f8c14b 36parser.add_argument('-v', '--verbose', action = 'store_true', help = 'Print verbose informations')
fdf3a386
ML
37
38args = parser.parse_args()
39
40benchmarks = os.listdir(args.location)
41
42for b in sorted(benchmarks):
43 dumps = []
44 for root, dirs, files in os.walk(os.path.join(args.location, b)):
45 for x in files:
46 if x.endswith('.profile'):
47 dumps.append(os.path.join(root, x))
48
49 if len(dumps) == 0:
50 continue
51
52 temp = tempfile.NamedTemporaryFile(delete = False)
53 for d in dumps:
54 temp.write(open(d, 'rb').read())
55
56 temp.close()
57
58 print()
31ab99f7 59 print(f' {b} '.center(160, '='))
fdf3a386 60 sys.stdout.flush()
ca3b6071
ML
61 p = [os.path.join(os.path.dirname(script_location), 'analyze_brprob.py'),
62 temp.name, '--sorting', args.sorting]
31ab99f7 63 if args.def_file:
59075bc8 64 p += ['-d', args.def_file]
31ab99f7
ML
65 if args.verbose:
66 p.append('-v')
59075bc8 67
fdf3a386
ML
68 p = subprocess.check_call(p)
69 sys.stdout.flush()
70
71 os.remove(temp.name)