Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 """Generate a spatial analysis against an arbitrary library. | 6 """Generate a spatial analysis against an arbitrary library. |
| 7 | 7 |
| 8 To use, build the 'binary_size_tool' target. Then run this tool, passing | 8 To use, build the 'binary_size_tool' target. Then run this tool, passing |
| 9 in the location of the library to be analyzed along with any other options | 9 in the location of the library to be analyzed along with any other options |
| 10 you desire. | 10 you desire. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 largest_list_len = child_largest_list_len | 81 largest_list_len = child_largest_list_len |
| 82 child_list.append(child) | 82 child_list.append(child) |
| 83 node['children'] = child_list | 83 node['children'] = child_list |
| 84 | 84 |
| 85 return largest_list_len | 85 return largest_list_len |
| 86 | 86 |
| 87 | 87 |
| 88 def MakeCompactTree(symbols): | 88 def MakeCompactTree(symbols): |
| 89 result = {'n': '/', 'children': {}, 'k': 'p', 'maxDepth': 0} | 89 result = {'n': '/', 'children': {}, 'k': 'p', 'maxDepth': 0} |
| 90 seen_symbol_with_path = False | 90 seen_symbol_with_path = False |
| 91 cwd = os.path.abspath(os.getcwd()) | |
| 91 for symbol_name, symbol_type, symbol_size, file_path in symbols: | 92 for symbol_name, symbol_type, symbol_size, file_path in symbols: |
| 92 | 93 |
| 93 if 'vtable for ' in symbol_name: | 94 if 'vtable for ' in symbol_name: |
| 94 symbol_type = '@' # hack to categorize these separately | 95 symbol_type = '@' # hack to categorize these separately |
| 95 # Take path like '/foo/bar/baz', convert to ['foo', 'bar', 'baz'] | 96 # Take path like '/foo/bar/baz', convert to ['foo', 'bar', 'baz'] |
| 96 if file_path: | 97 if file_path and file_path != "??": |
|
Primiano Tucci (use gerrit)
2014/05/27 09:06:26
Please be consistent with quotes (we tend to use s
| |
| 97 file_path = os.path.normpath(file_path) | 98 file_path = os.path.abspath(file_path) |
|
Primiano Tucci (use gerrit)
2014/05/27 09:06:26
Lines 98-100 look like re-implementing python
os.p
| |
| 99 if file_path.startswith(cwd + os.sep): | |
| 100 file_path = file_path[len(cwd):] | |
| 98 seen_symbol_with_path = True | 101 seen_symbol_with_path = True |
| 99 else: | 102 else: |
| 100 file_path = '(No Path)' | 103 file_path = '(No Path)' |
| 101 | 104 |
| 102 if file_path.startswith('/'): | 105 if file_path.startswith('/'): |
| 103 file_path = file_path[1:] | 106 file_path = file_path[1:] |
| 104 path_parts = file_path.split('/') | 107 path_parts = file_path.split('/') |
| 105 | 108 |
| 106 # Find pre-existing node in tree, or update if it already exists | 109 # Find pre-existing node in tree, or update if it already exists |
| 107 node = result | 110 node = result |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 427 progress = Progress() | 430 progress = Progress() |
| 428 def map_address_symbol(symbol, addr): | 431 def map_address_symbol(symbol, addr): |
| 429 progress.count += 1 | 432 progress.count += 1 |
| 430 if addr in address_symbol: | 433 if addr in address_symbol: |
| 431 # 'Collision between %s and %s.' % (str(symbol.name), | 434 # 'Collision between %s and %s.' % (str(symbol.name), |
| 432 # str(address_symbol[addr].name)) | 435 # str(address_symbol[addr].name)) |
| 433 progress.collisions += 1 | 436 progress.collisions += 1 |
| 434 else: | 437 else: |
| 435 address_symbol[addr] = symbol | 438 address_symbol[addr] = symbol |
| 436 | 439 |
| 440 progress_output() | |
| 441 | |
| 442 def progress_output(): | |
|
Primiano Tucci (use gerrit)
2014/05/27 09:06:26
Hmm what is the rationale of defining and calling
| |
| 437 progress_chunk = 100 | 443 progress_chunk = 100 |
| 438 if progress.count % progress_chunk == 0: | 444 if progress.count % progress_chunk == 0: |
| 439 time_now = time.time() | 445 time_now = time.time() |
| 440 time_spent = time_now - progress.time_last_output | 446 time_spent = time_now - progress.time_last_output |
| 441 if time_spent > 1.0: | 447 if time_spent > 1.0: |
| 442 # Only output at most once per second. | 448 # Only output at most once per second. |
| 443 progress.time_last_output = time_now | 449 progress.time_last_output = time_now |
| 444 chunk_size = progress.count - progress.count_last_output | 450 chunk_size = progress.count - progress.count_last_output |
| 445 progress.count_last_output = progress.count | 451 progress.count_last_output = progress.count |
| 446 if time_spent > 0: | 452 if time_spent > 0: |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 681 print('Copying index.html') | 687 print('Copying index.html') |
| 682 shutil.copy(os.path.join(template_src, 'index.html'), opts.destdir) | 688 shutil.copy(os.path.join(template_src, 'index.html'), opts.destdir) |
| 683 shutil.copy(os.path.join(template_src, 'D3SymbolTreeMap.js'), opts.destdir) | 689 shutil.copy(os.path.join(template_src, 'D3SymbolTreeMap.js'), opts.destdir) |
| 684 | 690 |
| 685 if opts.verbose: | 691 if opts.verbose: |
| 686 print 'Report saved to ' + opts.destdir + '/index.html' | 692 print 'Report saved to ' + opts.destdir + '/index.html' |
| 687 | 693 |
| 688 | 694 |
| 689 if __name__ == '__main__': | 695 if __name__ == '__main__': |
| 690 sys.exit(main()) | 696 sys.exit(main()) |
| OLD | NEW |