Skip to content

analyze_code_size.py: Improve recognition of nested class types and sort listing by size #32468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions utils/analyze_code_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,12 @@ def add(self, symbol):
self.size += symbol.size

def list_symbols(self):
sorted_symbols = []
for symbol in self.symbols:
print(" " + symbol.name + " " + str(symbol.size))
sorted_symbols.append((symbol.name, symbol.size))
sorted_symbols.sort(key=lambda entry: entry[1], reverse=True)
for symbol in sorted_symbols:
print("%9d %s" % (symbol[1], symbol[0]))


class Categories(object):
Expand Down Expand Up @@ -229,7 +233,7 @@ def __init__(self):
self.categories = {}
self.specializations = {}
self.specialization_matcher = re.compile(
r'.*generic specialization <(?P<spec_list>[^>]*)>.* of' +
r'.*generic specialization <(?P<spec_list>.*)> of' +
r' (static )?(\(extension in Swift\):)?(?P<module_name>[^.]*)\.' +
r'(?:(?P<first_type>[^.^(^<]*)\.){0,1}' +
r'(?:(?P<last_type>[^.^(^<]*)\.)*(?P<function_name>[^(^<]*)'
Expand All @@ -255,7 +259,7 @@ def __init__(self):
self.array_type_matcher = re.compile(r'Array')
self.dictionary = re.compile(r'Array')
self.single_specialized_types_matcher = re.compile(
r'(?P<module_name>[^,^.]*)\.(?P<type_name>[^,^.]*)$'
r'(?P<module_name>[^,^.]*)\.([^,^.]*\.)*(?P<type_name>[^,^.]*)$'
)
self.is_class_type_dict = {}
self.stdlib_and_other_type_matcher = re.compile(
Expand Down