| OLD | NEW |
| 1 # Copyright 2017 The Chromium Authors. All rights reserved. | 1 # Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 """Methods for converting model objects to human-readable formats.""" | 4 """Methods for converting model objects to human-readable formats.""" |
| 5 | 5 |
| 6 import datetime | 6 import datetime |
| 7 import itertools | 7 import itertools |
| 8 import time | 8 import time |
| 9 | 9 |
| 10 import models | 10 import models |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 def DescribeSizeInfoCoverage(size_info): | 269 def DescribeSizeInfoCoverage(size_info): |
| 270 """Yields lines describing how accurate |size_info| is.""" | 270 """Yields lines describing how accurate |size_info| is.""" |
| 271 for section in models.SECTION_TO_SECTION_NAME: | 271 for section in models.SECTION_TO_SECTION_NAME: |
| 272 if section == 'd': | 272 if section == 'd': |
| 273 expected_size = sum(v for k, v in size_info.section_sizes.iteritems() | 273 expected_size = sum(v for k, v in size_info.section_sizes.iteritems() |
| 274 if k.startswith('.data')) | 274 if k.startswith('.data')) |
| 275 else: | 275 else: |
| 276 expected_size = size_info.section_sizes[ | 276 expected_size = size_info.section_sizes[ |
| 277 models.SECTION_TO_SECTION_NAME[section]] | 277 models.SECTION_TO_SECTION_NAME[section]] |
| 278 | 278 |
| 279 # Use raw_symbols in case symbols contains groups. | 279 in_section = size_info.raw_symbols.WhereInSection(section) |
| 280 in_section = models.SymbolGroup(size_info.raw_symbols).WhereInSection( | |
| 281 section) | |
| 282 actual_size = in_section.size | 280 actual_size = in_section.size |
| 283 size_percent = _Divide(actual_size, expected_size) | 281 size_percent = _Divide(actual_size, expected_size) |
| 284 yield ('Section {}: has {:.1%} of {} bytes accounted for from ' | 282 yield ('Section {}: has {:.1%} of {} bytes accounted for from ' |
| 285 '{} symbols. {} bytes are unaccounted for.').format( | 283 '{} symbols. {} bytes are unaccounted for.').format( |
| 286 section, size_percent, actual_size, len(in_section), | 284 section, size_percent, actual_size, len(in_section), |
| 287 expected_size - actual_size) | 285 expected_size - actual_size) |
| 288 star_syms = in_section.WhereNameMatches(r'^\*') | 286 star_syms = in_section.WhereNameMatches(r'^\*') |
| 289 padding = in_section.padding - star_syms.padding | 287 padding = in_section.padding - star_syms.padding |
| 290 anonymous_syms = star_syms.Inverted().WhereHasAnyAttribution().Inverted() | 288 anonymous_syms = star_syms.Inverted().WhereHasAnyAttribution().Inverted() |
| 291 yield '* Padding accounts for {} bytes ({:.1%})'.format( | 289 yield '* Padding accounts for {} bytes ({:.1%})'.format( |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 | 339 |
| 342 def GenerateLines(obj, verbose=False, recursive=False): | 340 def GenerateLines(obj, verbose=False, recursive=False): |
| 343 """Returns an iterable of lines (without \n) that describes |obj|.""" | 341 """Returns an iterable of lines (without \n) that describes |obj|.""" |
| 344 return Describer(verbose=verbose, recursive=recursive).GenerateLines(obj) | 342 return Describer(verbose=verbose, recursive=recursive).GenerateLines(obj) |
| 345 | 343 |
| 346 | 344 |
| 347 def WriteLines(lines, func): | 345 def WriteLines(lines, func): |
| 348 for l in lines: | 346 for l in lines: |
| 349 func(l) | 347 func(l) |
| 350 func('\n') | 348 func('\n') |
| OLD | NEW |