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

Side by Side Diff: tools/binary_size/libsupersize/describe.py

Issue 2889603002: supersize: Add "printed" to console, Show ~0 for PSS >0 <.1 (Closed)
Patch Set: add in Symbol Group counter reset Created 3 years, 7 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
OLDNEW
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 19 matching lines...) Expand all
30 30
31 31
32 def _FormatPss(pss): 32 def _FormatPss(pss):
33 # Shows a decimal for small numbers to make it clear that a shared symbol has 33 # Shows a decimal for small numbers to make it clear that a shared symbol has
34 # a non-zero pss. 34 # a non-zero pss.
35 if pss > 10: 35 if pss > 10:
36 return str(int(pss)) 36 return str(int(pss))
37 ret = str(round(pss, 1)) 37 ret = str(round(pss, 1))
38 if ret.endswith('.0'): 38 if ret.endswith('.0'):
39 ret = ret[:-2] 39 ret = ret[:-2]
40 if ret == '0' and pss:
41 ret = '~0'
estevenson 2017/05/16 15:11:07 nit: won't this actually only return ~0 for 0 < ps
agrieve 2017/05/16 15:22:31 Fixed commit msg.
40 return ret 42 return ret
41 43
42 44
43 def _DiffPrefix(diff, sym): 45 def _DiffPrefix(diff, sym):
44 if diff.IsAdded(sym): 46 if diff.IsAdded(sym):
45 return '+ ' 47 return '+ '
46 if diff.IsRemoved(sym): 48 if diff.IsRemoved(sym):
47 return '- ' 49 return '- '
48 if sym.size: 50 if sym.size:
49 return '~ ' 51 return '~ '
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 unique_paths = set() 157 unique_paths = set()
156 for s in group.IterLeafSymbols(): 158 for s in group.IterLeafSymbols():
157 if s.section == 't': 159 if s.section == 't':
158 code_size += s.pss 160 code_size += s.pss
159 elif s.section == 'r': 161 elif s.section == 'r':
160 ro_size += s.pss 162 ro_size += s.pss
161 elif s.section == 'd': 163 elif s.section == 'd':
162 data_size += s.pss 164 data_size += s.pss
163 elif s.section == 'b': 165 elif s.section == 'b':
164 bss_size += s.pss 166 bss_size += s.pss
165 unique_paths.add(s.object_path) 167 # Ignore paths like foo/{shared}/2
168 if '{' not in s.object_path:
169 unique_paths.add(s.object_path)
166 header_desc = [ 170 header_desc = [
167 'Showing {:,} symbols ({:,} unique) with total pss: {} bytes'.format( 171 'Showing {:,} symbols ({:,} unique) with total pss: {} bytes'.format(
168 len(group), group.CountUniqueSymbols(), int(total_size)), 172 len(group), group.CountUniqueSymbols(), int(total_size)),
169 '.text={:<10} .rodata={:<10} .data*={:<10} .bss={:<10} total={}'.format( 173 '.text={:<10} .rodata={:<10} .data*={:<10} .bss={:<10} total={}'.format(
170 _PrettySize(int(code_size)), _PrettySize(int(ro_size)), 174 _PrettySize(int(code_size)), _PrettySize(int(ro_size)),
171 _PrettySize(int(data_size)), _PrettySize(int(bss_size)), 175 _PrettySize(int(data_size)), _PrettySize(int(bss_size)),
172 _PrettySize(int(total_size))), 176 _PrettySize(int(total_size))),
173 'Number of object files: {}'.format(len(unique_paths)), 177 'Number of unique paths: {}'.format(len(unique_paths)),
174 '', 178 '',
175 'Index, Running Total, Section@Address, PSS', 179 'Index, Running Total, Section@Address, PSS',
176 '-' * 60 180 '-' * 60
177 ] 181 ]
178 children_desc = self._DescribeSymbolGroupChildren(group) 182 children_desc = self._DescribeSymbolGroupChildren(group)
179 return itertools.chain(header_desc, children_desc) 183 return itertools.chain(header_desc, children_desc)
180 184
181 def _DescribeSymbolDiff(self, diff): 185 def _DescribeSymbolDiff(self, diff):
182 header_template = ('{} symbols added (+), {} changed (~), {} removed (-), ' 186 header_template = ('{} symbols added (+), {} changed (~), {} removed (-), '
183 '{} unchanged ({})') 187 '{} unchanged ({})')
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 336
333 def GenerateLines(obj, verbose=False, recursive=False): 337 def GenerateLines(obj, verbose=False, recursive=False):
334 """Returns an iterable of lines (without \n) that describes |obj|.""" 338 """Returns an iterable of lines (without \n) that describes |obj|."""
335 return Describer(verbose=verbose, recursive=recursive).GenerateLines(obj) 339 return Describer(verbose=verbose, recursive=recursive).GenerateLines(obj)
336 340
337 341
338 def WriteLines(lines, func): 342 def WriteLines(lines, func):
339 for l in lines: 343 for l in lines:
340 func(l) 344 func(l)
341 func('\n') 345 func('\n')
OLDNEW
« no previous file with comments | « tools/binary_size/libsupersize/console.py ('k') | tools/binary_size/libsupersize/linker_map_parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698