blob: 000405fc8e2acbfffa831c5c1b669442d0cc0bd4 [file] [log] [blame]
Brian Osman5aa11fb2019-04-08 16:40:36 -04001# Copyright 2019 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5import json
6import os
7import subprocess
8import sys
9
10if len(sys.argv) != 3:
11 print sys.argv[0], ' <compiler> <folder>'
12 sys.exit(1)
13
14compiler = sys.argv[1]
15folder = sys.argv[2]
16
17FRAG_JSON = os.path.join(folder, 'frag.json')
18
19with open(FRAG_JSON) as f:
20 frags = json.load(f)
21
22if not frags:
23 print 'No JSON data'
24 sys.exit(1)
25
26for fragAndCount in frags:
27 source = os.path.join(folder, fragAndCount[0] + '.frag')
28 try:
29 output = subprocess.check_output([compiler, source])
30 except subprocess.CalledProcessError:
31 continue
32 for line in output.splitlines():
33 if line.startswith('Instructions Emitted'):
34 inst = line.split(':')[1].split()
35 print '{0} {1} {2} {3} {4}'.format(
36 fragAndCount[0], fragAndCount[1], inst[0], inst[1], inst[2])