Chromium Code Reviews| Index: tools/binary_size/libsupersize/precanned_queries.py |
| diff --git a/tools/binary_size/libsupersize/precanned_queries.py b/tools/binary_size/libsupersize/precanned_queries.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..ddb89698fc38e498214367e991626b421d6a4df8 |
| --- /dev/null |
| +++ b/tools/binary_size/libsupersize/precanned_queries.py |
| @@ -0,0 +1,110 @@ |
| +# Copyright 2017 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +"""Contains a set of Chrome-specific size queries.""" |
| + |
| +import logging |
| +import models |
| + |
| + |
| +class _Grouper(object): |
| + def __init__(self): |
| + self.groups = [] |
| + |
| + def Add(self, name, group): |
| + logging.debug('Computed %s', name) |
| + group.name = name |
| + self.groups.append(group) |
| + return group.Inverted() |
| + |
| + def Finalize(self, remaining): |
| + self.groups.sort(key=lambda s:(s.name.startswith('Other'), -s.pss)) |
| + if remaining: |
| + stars = remaining.Filter(lambda s: s.name.startswith('*')) |
| + if stars: |
| + remaining = stars.Inverted() |
| + stars.name = '** Merged Symbols' |
| + self.groups.append(stars) |
| + remaining.name = 'Other' |
| + self.groups.append(remaining) |
| + |
| + logging.debug('Finalized') |
| + return models.SymbolGroup(self.groups, is_sorted=True) |
| + |
| + |
| +def CategorizeByChromeComponent(symbols): |
| + g = _Grouper() |
| + |
| + # Put things that filter out a lot of symbols at the beginning where possible |
| + # to optimize speed. |
| + symbols = g.Add('WebRTC', symbols.WhereMatches(r'(?i)webrtc')) |
| + symbols = g.Add('Skia', symbols.Filter(lambda s: 'skia/' in s.source_path)) |
| + symbols = g.Add('V8', symbols.Filter( |
| + lambda s: s.source_path.startswith('v8/'))) |
| + |
| + # Next, put non-regex queries, since they're a bit faster. |
| + symbols = g.Add('ICU', symbols.Filter(lambda s: '/icu/' in s.source_path)) |
| + symbols = g.Add('Prefetch', symbols.Filter( |
| + lambda s: 'resource_prefetch' in s.source_path)) |
| + symbols = g.Add('Password Manager', symbols.Filter( |
| + lambda s: 'password_manager' in s.source_path)) |
| + symbols = g.Add('Internals Pages', symbols.Filter( |
| + lambda s: '_internals' in s.source_path)) |
| + symbols = g.Add('Autofill', symbols.WhereSourcePathMatches(r'(?i)autofill')) |
| + symbols = g.Add('WebGL', symbols.WhereMatches(r'(?i)webgl')) |
| + symbols = g.Add('WebBluetooth', symbols.WhereMatches(r'(?i)bluetooth')) |
| + symbols = g.Add('WebUSB', symbols.WhereMatches(r'(?i)webusb|(\b|_)usb(\b|_)')) |
| + symbols = g.Add('WebVR', symbols.WhereMatches( |
| + r'{{_gvr_}}|{{_cwebvr_}}|{{_vr_}}')) |
| + symbols = g.Add('FileSystem', symbols.WhereSourcePathMatches( |
| + r'content/.*/fileapi|WebKit/.*/filesystem')) |
| + symbols = g.Add('WebCrypto', symbols.WhereMatches(r'(?i)webcrypto')) |
| + symbols = g.Add('Printing', symbols.WhereMatches(r'printing')) |
| + symbols = g.Add('Cast', symbols.WhereSourcePathMatches( |
| + r'(?i)(\b|_)cast(\b|_)')) |
| + symbols = g.Add('Media Source', symbols.WhereMatches( |
| + r'(?i)mediasource|blink::.*TrackDefault|blink::.*SourceBuffer')) |
| + |
| + # XSLT must come before libxml. |
| + symbols = g.Add('XSLT', symbols.WhereMatches(r'(?i)xslt')) |
| + symbols = g.Add('libxml', symbols.Filter( |
| + lambda s: 'libxml' in s.source_path)) |
| + |
| + # These have some overlap with above, so need to come afterwards. |
| + blink_syms = symbols.WhereSourcePathMatches(r'\b(blink|WebKit)\b') |
| + symbols = blink_syms.Inverted() |
| + blink_generated = blink_syms.WhereSourceIsGenerated() |
| + g.Add('Blink (generated)', blink_generated) |
| + g.Add('Blink (non-generated)', blink_generated.Inverted()) |
| + |
| + symbols = g.Add('Codecs', symbols.WhereSourcePathMatches( |
| + r'^third_party/(libweb[mp]|libpng|libjpeg_turbo|opus|ffmpeg|libvpx)/')) |
| + symbols = g.Add('Other Third-Party', symbols.Filter( |
| + lambda s: 'third_party' in s.source_path)) |
| + |
| + return g.Finalize(symbols) |
| + |
| + |
| +def CategorizeGenerated(symbols): |
|
estevenson
2017/05/05 22:24:18
Could add jni here? Might be super small though.
agrieve
2017/05/06 01:18:22
Done. ~50kb. But the number doesn't capture many o
|
| + g = _Grouper() |
| + symbols = symbols.WhereSourceIsGenerated() |
| + symbols = g.Add('Protocol Buffers', symbols.Filter(lambda s: ( |
| + '/protobuf/' in s.object_path or |
| + s.object_path.endswith('.pbzero.o') or |
| + s.object_path.endswith('.pb.o')))) |
| + symbols = g.Add('Mojo', symbols.Filter(lambda s: ( |
| + '.mojom' in s.source_path or # Blink uses .mojom-blink.cc |
| + s.source_path.startswith('mojo/') or |
| + s.name.startswith('mojo::')))) |
| + symbols = g.Add('DevTools', symbols.WhereSourcePathMatches( |
| + r'\b(?:protocol|devtools)\b')) |
| + symbols = g.Add('Blink (bindings)', symbols.Filter(lambda s: ( |
| + 'blink/bindings' in s.source_path or |
| + ('WebKit/' in s.object_path and '/bindings/' in s.object_path)))) |
| + symbols = g.Add('Blink (IDL)', symbols.Filter(lambda s: ( |
| + 'WebKit/Source/core' in s.object_path))) |
| + symbols = g.Add('Blink (Other)', symbols.Filter(lambda s: ( |
| + 'WebKit' in s.object_path or 'blink/' in s.object_path))) |
| + |
| + return g.Finalize(symbols) |