]>
Commit | Line | Data |
---|---|---|
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 | ||
21 | import sys | |
22 | import os | |
23 | import subprocess | |
24 | import tempfile | |
25 | import argparse | |
26 | ||
27 | script_location = os.path.realpath(__file__) | |
28 | ||
29 | parser = argparse.ArgumentParser() | |
ca3b6071 | 30 | parser.add_argument('location', metavar = 'dump_file', |
31ab99f7 | 31 | help = 'Sub-folder with SPEC benchmarks (e.g. Programming/cpu2017/benchspec/CPU)') |
ca3b6071 ML |
32 | parser.add_argument('-s', '--sorting', dest = 'sorting', |
33 | choices = ['branches', 'branch-hitrate', 'hitrate', 'coverage', 'name'], | |
34 | default = 'branches') | |
59075bc8 | 35 | parser.add_argument('-d', '--def-file', help = 'path to predict.def') |
e1f8c14b | 36 | parser.add_argument('-v', '--verbose', action = 'store_true', help = 'Print verbose informations') |
fdf3a386 ML |
37 | |
38 | args = parser.parse_args() | |
39 | ||
40 | benchmarks = os.listdir(args.location) | |
41 | ||
42 | for 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) |