Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: tools/binary_size/create_html_breakdown.py

Issue 2809043003: //tools/binary_size: Group [clone] and ** symbols (Closed)
Patch Set: review comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/binary_size/console.py ('k') | tools/binary_size/describe.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Creates an html report that allows you to view binary size by component.""" 6 """Creates an html report that allows you to view binary size by component."""
7 7
8 import argparse 8 import argparse
9 import json 9 import json
10 import logging 10 import logging
11 import os 11 import os
12 import shutil 12 import shutil
13 import sys 13 import sys
14 14
15 import helpers 15 import helpers
16 import map2size 16 import map2size
17 import paths
18 17
19 18
20 # Node dictionary keys. These are output in json read by the webapp so 19 # Node dictionary keys. These are output in json read by the webapp so
21 # keep them short to save file size. 20 # keep them short to save file size.
22 # Note: If these change, the webapp must also change. 21 # Note: If these change, the webapp must also change.
23 _NODE_TYPE_KEY = 'k' 22 _NODE_TYPE_KEY = 'k'
24 _NODE_TYPE_BUCKET = 'b' 23 _NODE_TYPE_BUCKET = 'b'
25 _NODE_TYPE_PATH = 'p' 24 _NODE_TYPE_PATH = 'p'
26 _NODE_TYPE_SYMBOL = 's' 25 _NODE_TYPE_SYMBOL = 's'
27 _NODE_NAME_KEY = 'n' 26 _NODE_NAME_KEY = 'n'
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 template_src = os.path.join(os.path.dirname(__file__), 'template') 159 template_src = os.path.join(os.path.dirname(__file__), 'template')
161 shutil.copy(os.path.join(d3_src, 'LICENSE'), d3_out) 160 shutil.copy(os.path.join(d3_src, 'LICENSE'), d3_out)
162 shutil.copy(os.path.join(d3_src, 'd3.js'), d3_out) 161 shutil.copy(os.path.join(d3_src, 'd3.js'), d3_out)
163 shutil.copy(os.path.join(template_src, 'index.html'), dest_dir) 162 shutil.copy(os.path.join(template_src, 'index.html'), dest_dir)
164 shutil.copy(os.path.join(template_src, 'D3SymbolTreeMap.js'), dest_dir) 163 shutil.copy(os.path.join(template_src, 'D3SymbolTreeMap.js'), dest_dir)
165 164
166 165
167 def main(argv): 166 def main(argv):
168 parser = argparse.ArgumentParser() 167 parser = argparse.ArgumentParser()
169 parser.add_argument('input_file', 168 parser.add_argument('input_file',
170 help='Path to input file. Can be a linker .map file, or ' 169 help='Path to input .size file.')
171 'a .size file.')
172 parser.add_argument('--report-dir', metavar='PATH', required=True, 170 parser.add_argument('--report-dir', metavar='PATH', required=True,
173 help='Write output to the specified directory. An HTML ' 171 help='Write output to the specified directory. An HTML '
174 'report is generated here.') 172 'report is generated here.')
175 parser.add_argument('--include-bss', action='store_true', 173 parser.add_argument('--include-bss', action='store_true',
176 help='Include symbols from .bss (which consume no real ' 174 help='Include symbols from .bss (which consume no real '
177 'space)') 175 'space)')
178 parser.add_argument('--include-symbols', action='store_true', 176 parser.add_argument('--include-symbols', action='store_true',
179 help='Use per-symbol granularity rather than per-file.') 177 help='Use per-symbol granularity rather than per-file.')
180 paths.AddOptions(parser)
181 args = helpers.AddCommonOptionsAndParseArgs(parser, argv) 178 args = helpers.AddCommonOptionsAndParseArgs(parser, argv)
182 179
183 lazy_paths = paths.LazyPaths(args=args, input_file=args.input_file) 180 size_info = map2size.LoadAndPostProcessSizeInfo(args.input_file)
184 size_info = map2size.Analyze(args.input_file, lazy_paths)
185 symbols = size_info.symbols 181 symbols = size_info.symbols
186 if not args.include_bss: 182 if not args.include_bss:
187 symbols = symbols.WhereInSection('b').Inverted() 183 symbols = symbols.WhereInSection('b').Inverted()
188 symbols = symbols.WhereBiggerThan(0) 184 symbols = symbols.WhereBiggerThan(0)
189 185
190 # Copy report boilerplate into output directory. This also proves that the 186 # Copy report boilerplate into output directory. This also proves that the
191 # output directory is safe for writing, so there should be no problems writing 187 # output directory is safe for writing, so there should be no problems writing
192 # the nm.out file later. 188 # the nm.out file later.
193 _CopyTemplateFiles(args.report_dir) 189 _CopyTemplateFiles(args.report_dir)
194 190
195 logging.info('Creating JSON objects') 191 logging.info('Creating JSON objects')
196 tree_root = _MakeCompactTree(symbols, args.include_symbols) 192 tree_root = _MakeCompactTree(symbols, args.include_symbols)
197 193
198 logging.info('Serializing') 194 logging.info('Serializing')
199 with open(os.path.join(args.report_dir, 'data.js'), 'w') as out_file: 195 with open(os.path.join(args.report_dir, 'data.js'), 'w') as out_file:
200 out_file.write('var tree_data=') 196 out_file.write('var tree_data=')
201 # Use separators without whitespace to get a smaller file. 197 # Use separators without whitespace to get a smaller file.
202 json.dump(tree_root, out_file, ensure_ascii=False, check_circular=False, 198 json.dump(tree_root, out_file, ensure_ascii=False, check_circular=False,
203 separators=(',', ':')) 199 separators=(',', ':'))
204 200
205 print 'Report saved to ' + args.report_dir + '/index.html' 201 print 'Report saved to ' + args.report_dir + '/index.html'
206 202
207 203
208 if __name__ == '__main__': 204 if __name__ == '__main__':
209 sys.exit(main(sys.argv)) 205 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « tools/binary_size/console.py ('k') | tools/binary_size/describe.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698