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

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

Issue 2869873002: supersize: Sort diffs by default (Closed)
Patch Set: 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 """Logic for diffing two SizeInfo objects.""" 4 """Logic for diffing two SizeInfo objects."""
5 5
6 import collections 6 import collections
7 import re 7 import re
8 8
9 import models 9 import models
10 10
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 for section_name, padding in padding_by_section_name.iteritems(): 173 for section_name, padding in padding_by_section_name.iteritems():
174 if padding != 0: 174 if padding != 0:
175 similar.append(models.Symbol( 175 similar.append(models.Symbol(
176 section_name, padding, 176 section_name, padding,
177 name="** aggregate padding of diff'ed symbols")) 177 name="** aggregate padding of diff'ed symbols"))
178 return models.SymbolDiff( 178 return models.SymbolDiff(
179 added, removed, similar, name=after.name, full_name=after.full_name, 179 added, removed, similar, name=after.name, full_name=after.full_name,
180 section_name=after.section_name) 180 section_name=after.section_name)
181 181
182 182
183 def Diff(before, after, cluster=True): 183 def Diff(before, after):
184 """Diffs two SizeInfo objects. Returns a SizeInfoDiff. 184 """Diffs two SizeInfo objects. Returns a SizeInfoDiff."""
185
186 Args:
187 cluster: When True, calls SymbolGroup.Cluster() after diffing. This
188 generally reduces noise.
189 """
190 assert isinstance(before, models.SizeInfo) 185 assert isinstance(before, models.SizeInfo)
191 assert isinstance(after, models.SizeInfo) 186 assert isinstance(after, models.SizeInfo)
192 section_sizes = {k: after.section_sizes[k] - v 187 section_sizes = {k: after.section_sizes[k] - v
193 for k, v in before.section_sizes.iteritems()} 188 for k, v in before.section_sizes.iteritems()}
194 symbol_diff = _DiffSymbolGroups(before.symbols, after.symbols) 189 symbol_diff = _DiffSymbolGroups(before.symbols, after.symbols)
195 if cluster:
196 symbol_diff = symbol_diff.Cluster()
197 return models.SizeInfoDiff(section_sizes, symbol_diff, before.metadata, 190 return models.SizeInfoDiff(section_sizes, symbol_diff, before.metadata,
198 after.metadata) 191 after.metadata)
OLDNEW
« no previous file with comments | « tools/binary_size/libsupersize/console.py ('k') | tools/binary_size/libsupersize/integration_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698