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

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

Issue 2775173005: FREEZE.unindexed (Closed)
Patch Set: ps2 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
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 115
116 def _MakeCompactTree(symbols, include_symbols): 116 def _MakeCompactTree(symbols, include_symbols):
117 result = { 117 result = {
118 _NODE_NAME_KEY: '/', 118 _NODE_NAME_KEY: '/',
119 _NODE_CHILDREN_KEY: {}, 119 _NODE_CHILDREN_KEY: {},
120 _NODE_TYPE_KEY: 'p', 120 _NODE_TYPE_KEY: 'p',
121 _NODE_MAX_DEPTH_KEY: 0, 121 _NODE_MAX_DEPTH_KEY: 0,
122 } 122 }
123 for symbol in symbols: 123 for symbol in symbols:
124 file_path = symbol.path or _NAME_NO_PATH_BUCKET 124 file_path = symbol.source_path or symbol.object_path or _NAME_NO_PATH_BUCKET
125 node = result 125 node = result
126 depth = 0 126 depth = 0
127 for path_part in file_path.split(os.path.sep): 127 for path_part in file_path.split(os.path.sep):
128 if not path_part: 128 if not path_part:
129 continue 129 continue
130 depth += 1 130 depth += 1
131 node = _GetOrMakeChildNode(node, _NODE_TYPE_PATH, path_part) 131 node = _GetOrMakeChildNode(node, _NODE_TYPE_PATH, path_part)
132 132
133 symbol_type = symbol.section 133 symbol_type = symbol.section
134 if symbol.name.endswith('[vtable]'): 134 if symbol.name.endswith('[vtable]'):
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 help='Include symbols from .bss (which consume no real ' 175 help='Include symbols from .bss (which consume no real '
176 'space)') 176 'space)')
177 parser.add_argument('--include-symbols', action='store_true', 177 parser.add_argument('--include-symbols', action='store_true',
178 help='Use per-symbol granularity rather than per-file.') 178 help='Use per-symbol granularity rather than per-file.')
179 map2size.AddOptions(parser) 179 map2size.AddOptions(parser)
180 args = helpers.AddCommonOptionsAndParseArgs(parser, argv) 180 args = helpers.AddCommonOptionsAndParseArgs(parser, argv)
181 181
182 size_info = map2size.AnalyzeWithArgs(args, args.input_file) 182 size_info = map2size.AnalyzeWithArgs(args, args.input_file)
183 symbols = size_info.symbols 183 symbols = size_info.symbols
184 if not args.include_bss: 184 if not args.include_bss:
185 symbols = size_info.WhereInSection('b').Inverted() 185 symbols = symbols.WhereInSection('b').Inverted()
186 symbols = symbols.WhereBiggerThan(0) 186 symbols = symbols.WhereBiggerThan(0)
187 187
188 # Copy report boilerplate into output directory. This also proves that the 188 # Copy report boilerplate into output directory. This also proves that the
189 # output directory is safe for writing, so there should be no problems writing 189 # output directory is safe for writing, so there should be no problems writing
190 # the nm.out file later. 190 # the nm.out file later.
191 _CopyTemplateFiles(args.report_dir) 191 _CopyTemplateFiles(args.report_dir)
192 192
193 logging.info('Creating JSON objects') 193 logging.info('Creating JSON objects')
194 tree_root = _MakeCompactTree(symbols, args.include_symbols) 194 tree_root = _MakeCompactTree(symbols, args.include_symbols)
195 195
196 logging.info('Serializing') 196 logging.info('Serializing')
197 with open(os.path.join(args.report_dir, 'data.js'), 'w') as out_file: 197 with open(os.path.join(args.report_dir, 'data.js'), 'w') as out_file:
198 out_file.write('var tree_data=') 198 out_file.write('var tree_data=')
199 # Use separators without whitespace to get a smaller file. 199 # Use separators without whitespace to get a smaller file.
200 json.dump(tree_root, out_file, ensure_ascii=False, check_circular=False, 200 json.dump(tree_root, out_file, ensure_ascii=False, check_circular=False,
201 separators=(',', ':')) 201 separators=(',', ':'))
202 202
203 print 'Report saved to ' + args.report_dir + '/index.html' 203 print 'Report saved to ' + args.report_dir + '/index.html'
204 204
205 205
206 if __name__ == '__main__': 206 if __name__ == '__main__':
207 sys.exit(main(sys.argv)) 207 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