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

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

Issue 2792403002: //tools/binary_size: Change merge symbols to have their size as padding (Closed)
Patch Set: rebase 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/map2size.py ('k') | tools/binary_size/testdata/ActualDiff.golden » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 """Classes that comprise the data model for binary size analysis.""" 4 """Classes that comprise the data model for binary size analysis."""
5 5
6 import collections 6 import collections
7 import copy 7 import copy
8 import os 8 import os
9 import re 9 import re
10 10
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 self.full_name = full_name or '' 106 self.full_name = full_name or ''
107 self.source_path = source_path or '' 107 self.source_path = source_path or ''
108 self.object_path = object_path or '' 108 self.object_path = object_path or ''
109 self.size = size_without_padding 109 self.size = size_without_padding
110 # Change this to be a bitfield of flags if ever there is a need to add 110 # Change this to be a bitfield of flags if ever there is a need to add
111 # another similar thing. 111 # another similar thing.
112 self.is_anonymous = is_anonymous 112 self.is_anonymous = is_anonymous
113 self.padding = 0 113 self.padding = 0
114 114
115 def __repr__(self): 115 def __repr__(self):
116 return '%s@%x(size=%d,padding=%d,name=%s,path=%s,anon=%d)' % ( 116 return ('%s@%x(size_without_padding=%d,padding=%d,name=%s,path=%s,anon=%d)'
117 self.section_name, self.address, self.size_without_padding, 117 % (self.section_name, self.address, self.size_without_padding,
118 self.padding, self.name, self.source_path or self.object_path, 118 self.padding, self.name, self.source_path or self.object_path,
119 int(self.is_anonymous)) 119 int(self.is_anonymous)))
120 120
121 121
122 class SymbolGroup(BaseSymbol): 122 class SymbolGroup(BaseSymbol):
123 """Represents a group of symbols using the same interface as Symbol. 123 """Represents a group of symbols using the same interface as Symbol.
124 124
125 SymbolGroups are immutable. All filtering / sorting will return new 125 SymbolGroups are immutable. All filtering / sorting will return new
126 SymbolGroups objects. 126 SymbolGroups objects.
127 127
128 Overrides many __functions__. E.g. the following are all valid: 128 Overrides many __functions__. E.g. the following are all valid:
129 * len(group) 129 * len(group)
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 566
567 for remaining_syms in symbols_by_key.itervalues(): 567 for remaining_syms in symbols_by_key.itervalues():
568 for old_sym in remaining_syms: 568 for old_sym in remaining_syms:
569 duped = copy.copy(old_sym) 569 duped = copy.copy(old_sym)
570 duped.size = -duped.size 570 duped.size = -duped.size
571 duped.padding = -duped.padding 571 duped.padding = -duped.padding
572 removed.append(duped) 572 removed.append(duped)
573 573
574 for section_name, padding in padding_by_section_name.iteritems(): 574 for section_name, padding in padding_by_section_name.iteritems():
575 similar.append(Symbol(section_name, padding, 575 similar.append(Symbol(section_name, padding,
576 name='** aggregate padding of delta symbols')) 576 name="** aggregate padding of diff'ed symbols"))
577 return SymbolDiff(added, removed, similar) 577 return SymbolDiff(added, removed, similar)
578 578
579 579
580 def _ExtractPrefixBeforeSeparator(string, separator, count=1): 580 def _ExtractPrefixBeforeSeparator(string, separator, count=1):
581 idx = -len(separator) 581 idx = -len(separator)
582 prev_idx = None 582 prev_idx = None
583 for _ in xrange(count): 583 for _ in xrange(count):
584 idx = string.find(separator, idx + len(separator)) 584 idx = string.find(separator, idx + len(separator))
585 if idx < 0: 585 if idx < 0:
586 break 586 break
587 prev_idx = idx 587 prev_idx = idx
588 return string[:prev_idx] 588 return string[:prev_idx]
OLDNEW
« no previous file with comments | « tools/binary_size/map2size.py ('k') | tools/binary_size/testdata/ActualDiff.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698