6"""Writes a Perf-formated json file with stats about the given cpp file."""
9from __future__
import print_function
19 input_file = sys.argv[1]
23 bloaty_path = sys.argv[5]
24 total_size_bytes_key = sys.argv[6]
25 magic_seperator = sys.argv[7]
32 props = propstr.split(
' ')
33 for i
in range(0,
len(props), 2):
34 results[props[i]] = props[i+1]
36 keys = keystr.split(
' ')
37 for i
in range(0,
len(keys), 2):
38 results[
'key'][keys[i]] = keys[i+1]
41 print(magic_seperator)
42 print(
'Note that template instantiations are grouped together, '
43 'thus the elided types.')
44 print(subprocess.check_output([bloaty_path, input_file,
45 '-d',
'sections,shortsymbols',
'-n',
'200']))
48 sections = subprocess.check_output([bloaty_path, input_file,
'-d',
49 'sections',
'-n',
'0',
'--csv'])
51 name = os.path.basename(input_file)
56 total_size_bytes_key: os.path.getsize(input_file)
61 for section_row
in sections.strip().split(
'\n'):
63 parts = section_row.split(
',')
64 if len(parts) < 3
or parts[0] ==
'sections':
74 section = re.sub(
'[^0-9a-zA-Z_]',
'_', section)
75 r[
'section'+section] = {
76 'in_file_size_bytes':
int(filesize),
77 'vm_size_bytes':
int(vmsize),
80 print(magic_seperator)
81 results[
'results'][name] = r
84 print(json.dumps(results, indent=2))
86 with open(os.path.join(out_dir, name+
'.json'),
'w')
as output:
87 output.write(json.dumps(results, indent=2))
90if __name__ ==
'__main__':
def print(*args, **kwargs)