111
|
1 #!/usr/bin/env python3
|
|
2
|
|
3 # This file is part of GCC.
|
|
4 #
|
|
5 # GCC is free software; you can redistribute it and/or modify it under
|
|
6 # the terms of the GNU General Public License as published by the Free
|
|
7 # Software Foundation; either version 3, or (at your option) any later
|
|
8 # version.
|
|
9 #
|
|
10 # GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
13 # for more details.
|
|
14 #
|
|
15 # You should have received a copy of the GNU General Public License
|
|
16 # along with GCC; see the file COPYING3. If not see
|
|
17 # <http://www.gnu.org/licenses/>. */
|
|
18
|
|
19 import sys
|
|
20 import os
|
|
21 import subprocess
|
|
22 import tempfile
|
|
23 import argparse
|
|
24
|
|
25 script_location = os.path.realpath(__file__)
|
|
26
|
|
27 parser = argparse.ArgumentParser()
|
|
28 parser.add_argument('location', metavar = 'dump_file',
|
|
29 help = 'Location with SPEC benchmarks')
|
|
30 parser.add_argument('-s', '--sorting', dest = 'sorting',
|
|
31 choices = ['branches', 'branch-hitrate', 'hitrate', 'coverage', 'name'],
|
|
32 default = 'branches')
|
|
33 parser.add_argument('-d', '--def-file', help = 'path to predict.def')
|
|
34
|
|
35 args = parser.parse_args()
|
|
36
|
|
37 benchmarks = os.listdir(args.location)
|
|
38
|
|
39 for b in sorted(benchmarks):
|
|
40 dumps = []
|
|
41 for root, dirs, files in os.walk(os.path.join(args.location, b)):
|
|
42 for x in files:
|
|
43 if x.endswith('.profile'):
|
|
44 dumps.append(os.path.join(root, x))
|
|
45
|
|
46 if len(dumps) == 0:
|
|
47 continue
|
|
48
|
|
49 temp = tempfile.NamedTemporaryFile(delete = False)
|
|
50 for d in dumps:
|
|
51 temp.write(open(d, 'rb').read())
|
|
52
|
|
53 temp.close()
|
|
54
|
|
55 print()
|
|
56 print(b)
|
|
57 sys.stdout.flush()
|
|
58 p = [os.path.join(os.path.dirname(script_location), 'analyze_brprob.py'),
|
|
59 temp.name, '--sorting', args.sorting]
|
|
60 if args.def_file != None:
|
|
61 p += ['-d', args.def_file]
|
|
62
|
|
63 p = subprocess.check_call(p)
|
|
64 sys.stdout.flush()
|
|
65
|
|
66 os.remove(temp.name)
|