Skip to content

Commit acc860a

Browse files
committed
analyze_code_size.py: Improve recognition of nested class types and
sort listing by size
1 parent eae52e1 commit acc860a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

utils/analyze_code_size.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,12 @@ def add(self, symbol):
124124
self.size += symbol.size
125125

126126
def list_symbols(self):
127+
sorted_symbols = []
127128
for symbol in self.symbols:
128-
print(" " + symbol.name + " " + str(symbol.size))
129+
sorted_symbols.append((symbol.name, symbol.size))
130+
sorted_symbols.sort(key=lambda entry: entry[1], reverse=True)
131+
for symbol in sorted_symbols:
132+
print("%9d %s" % (symbol[1], symbol[0]))
129133

130134

131135
class Categories(object):
@@ -229,7 +233,7 @@ def __init__(self):
229233
self.categories = {}
230234
self.specializations = {}
231235
self.specialization_matcher = re.compile(
232-
r'.*generic specialization <(?P<spec_list>[^>]*)>.* of' +
236+
r'.*generic specialization <(?P<spec_list>.*)> of' +
233237
r' (static )?(\(extension in Swift\):)?(?P<module_name>[^.]*)\.' +
234238
r'(?:(?P<first_type>[^.^(^<]*)\.){0,1}' +
235239
r'(?:(?P<last_type>[^.^(^<]*)\.)*(?P<function_name>[^(^<]*)'
@@ -255,7 +259,7 @@ def __init__(self):
255259
self.array_type_matcher = re.compile(r'Array')
256260
self.dictionary = re.compile(r'Array')
257261
self.single_specialized_types_matcher = re.compile(
258-
r'(?P<module_name>[^,^.]*)\.(?P<type_name>[^,^.]*)$'
262+
r'(?P<module_name>[^,^.]*)\.([^,^.]*\.)*(?P<type_name>[^,^.]*)$'
259263
)
260264
self.is_class_type_dict = {}
261265
self.stdlib_and_other_type_matcher = re.compile(

0 commit comments

Comments
 (0)