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

Unified Diff: tools/binary_size/create_html_breakdown.py

Issue 2785483002: Reland of V2 of //tools/binary_size rewrite (diffs). (Closed)
Patch Set: add missing name= Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/binary_size/console.py ('k') | tools/binary_size/describe.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/binary_size/create_html_breakdown.py
diff --git a/tools/binary_size/create_html_breakdown.py b/tools/binary_size/create_html_breakdown.py
index 8808776cab83f348d91b0a7dfa520e693f4ed822..7b45ae7ad42ff6d26879217f5b41ec6605220572 100755
--- a/tools/binary_size/create_html_breakdown.py
+++ b/tools/binary_size/create_html_breakdown.py
@@ -12,8 +12,8 @@ import os
import shutil
import sys
-import analyze
import helpers
+import map2size
# Node dictionary keys. These are output in json read by the webapp so
@@ -113,14 +113,14 @@ def _AddSymbolIntoFileNode(node, symbol_type, symbol_name, symbol_size,
node[_NODE_SYMBOL_TYPE_KEY] = symbol_type
-def _MakeCompactTree(root_group, include_symbols):
+def _MakeCompactTree(symbols, include_symbols):
result = {
_NODE_NAME_KEY: '/',
_NODE_CHILDREN_KEY: {},
_NODE_TYPE_KEY: 'p',
_NODE_MAX_DEPTH_KEY: 0,
}
- for symbol in root_group:
+ for symbol in symbols:
file_path = symbol.path or _NAME_NO_PATH_BUCKET
node = result
depth = 0
@@ -131,11 +131,10 @@ def _MakeCompactTree(root_group, include_symbols):
node = _GetOrMakeChildNode(node, _NODE_TYPE_PATH, path_part)
symbol_type = symbol.section
- if symbol.name:
- if symbol.name.endswith('[vtable]'):
- symbol_type = _NODE_SYMBOL_TYPE_VTABLE
- elif symbol.name.endswith(']'):
- symbol_type = _NODE_SYMBOL_TYPE_GENERATED
+ if symbol.name.endswith('[vtable]'):
+ symbol_type = _NODE_SYMBOL_TYPE_VTABLE
+ elif symbol.name.endswith(']'):
+ symbol_type = _NODE_SYMBOL_TYPE_GENERATED
_AddSymbolIntoFileNode(node, symbol_type, symbol.name, symbol.size,
include_symbols)
depth += 2
@@ -164,8 +163,11 @@ def _CopyTemplateFiles(dest_dir):
shutil.copy(os.path.join(template_src, 'D3SymbolTreeMap.js'), dest_dir)
-def main():
+def main(argv):
parser = argparse.ArgumentParser()
+ parser.add_argument('input_file',
+ help='Path to input file. Can be a linker .map file, or '
+ 'a .size file.')
parser.add_argument('--report-dir', metavar='PATH', required=True,
help='Write output to the specified directory. An HTML '
'report is generated here.')
@@ -174,14 +176,14 @@ def main():
'space)')
parser.add_argument('--include-symbols', action='store_true',
help='Use per-symbol granularity rather than per-file.')
- analyze.AddOptions(parser)
- args = helpers.AddCommonOptionsAndParseArgs(parser)
+ map2size.AddOptions(parser)
+ args = helpers.AddCommonOptionsAndParseArgs(parser, argv)
- result = analyze.AnalyzeWithArgs(args)
- root_group = result.symbol_group
+ size_info = map2size.AnalyzeWithArgs(args, args.input_file)
+ symbols = size_info.symbols
if not args.include_bss:
- root_group = root_group.WhereInSection('b').Inverted()
- root_group = root_group.WhereBiggerThan(0)
+ symbols = size_info.WhereInSection('b').Inverted()
+ symbols = symbols.WhereBiggerThan(0)
# Copy report boilerplate into output directory. This also proves that the
# output directory is safe for writing, so there should be no problems writing
@@ -189,7 +191,7 @@ def main():
_CopyTemplateFiles(args.report_dir)
logging.info('Creating JSON objects')
- tree_root = _MakeCompactTree(root_group, args.include_symbols)
+ tree_root = _MakeCompactTree(symbols, args.include_symbols)
logging.info('Serializing')
with open(os.path.join(args.report_dir, 'data.js'), 'w') as out_file:
@@ -200,5 +202,6 @@ def main():
print 'Report saved to ' + args.report_dir + '/index.html'
+
if __name__ == '__main__':
- sys.exit(main())
+ sys.exit(main(sys.argv))
« 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