blob: d437e61b1f69e254b21b1db8104a18f01a9809bd [file] [log] [blame]
# Copyright 2019 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import json
import os
import subprocess
import sys
if len(sys.argv) != 3:
print sys.argv[0], ' <compiler> <folder>'
compiler = sys.argv[1]
folder = sys.argv[2]
stats = {}
for filename in os.listdir(folder):
basename, ext = os.path.splitext(filename)
if ext not in ['.frag', '.spv']:
cmdline = [compiler]
if ext == '.spv':
cmdline.extend(['-f', '-p'])
cmdline.append(os.path.join(folder, filename))
output = subprocess.check_output(cmdline)
except subprocess.CalledProcessError:
stats.setdefault(basename, {})
for line in output.splitlines():
if line.startswith('Instructions Emitted'):
inst = line.split(':')[1].split()
stats[basename][ext] = inst
for k, v in stats.iteritems():
gl = v.get('.frag', ['', '', ''])
vk = v.get('.spv', ['', '', ''])
print '{0},{1},{2},{3},{4},{5},{6}'.format(k, gl[0], gl[1], gl[2], vk[0], vk[1], vk[2])