19 input_file = sys.argv[1]
20 out_dir = sys.argv[2]
21 keystr = sys.argv[3]
22 propstr = sys.argv[4]
23 bloaty_path = sys.argv[5]
24 total_size_bytes_key = sys.argv[6]
25 magic_seperator = sys.argv[7]
26
27 results = {
28 'key': { },
29 'results': { }
30 }
31
32 props = propstr.split(' ')
33 for i
in range(0,
len(props), 2):
34 results[props[i]] = props[i+1]
35
36 keys = keystr.split(' ')
37 for i
in range(0,
len(keys), 2):
38 results['key'][keys[i]] = keys[i+1]
39
40
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']))
47
48 sections = subprocess.check_output([bloaty_path, input_file, '-d',
49 'sections', '-n', '0', '--csv'])
50
51 name = os.path.basename(input_file)
52
53 r = {
54
55 'default' : {
56 total_size_bytes_key: os.path.getsize(input_file)
57 },
58 }
59
60
61 for section_row in sections.strip().split('\n'):
62
63 parts = section_row.split(',')
64 if len(parts) < 3
or parts[0] ==
'sections':
65
66 continue
67 section = parts[0]
68
69
70
71
72 vmsize = parts[1]
73 filesize = parts[2]
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),
78 }
79
80 print(magic_seperator)
81 results['results'][name] = r
82
83
84 print(json.dumps(results, indent=2))
85
86 with open(os.path.join(out_dir, name+'.json'), 'w') as output:
87 output.write(json.dumps(results, indent=2))
88
89
def print(*args, **kwargs)