Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 """Contains a set of Chrome-specific size queries.""" | |
| 6 | |
| 7 import logging | |
| 8 import models | |
| 9 | |
| 10 | |
| 11 class _Grouper(object): | |
| 12 def __init__(self): | |
| 13 self.groups = [] | |
| 14 | |
| 15 def Add(self, name, group): | |
| 16 logging.debug('Computed %s', name) | |
| 17 group.name = name | |
| 18 self.groups.append(group) | |
| 19 return group.Inverted() | |
| 20 | |
| 21 def Finalize(self, remaining): | |
| 22 self.groups.sort(key=lambda s:(s.name.startswith('Other'), -s.pss)) | |
| 23 if remaining: | |
| 24 stars = remaining.Filter(lambda s: s.name.startswith('*')) | |
| 25 if stars: | |
| 26 remaining = stars.Inverted() | |
| 27 stars.name = '** Merged Symbols' | |
| 28 self.groups.append(stars) | |
| 29 remaining.name = 'Other' | |
| 30 self.groups.append(remaining) | |
| 31 | |
| 32 logging.debug('Finalized') | |
| 33 return models.SymbolGroup(self.groups, is_sorted=True) | |
| 34 | |
| 35 | |
| 36 def CategorizeByChromeComponent(symbols): | |
| 37 g = _Grouper() | |
| 38 | |
| 39 # Put things that filter out a lot of symbols at the beginning where possible | |
| 40 # to optimize speed. | |
| 41 symbols = g.Add('WebRTC', symbols.WhereMatches(r'(?i)webrtc')) | |
| 42 symbols = g.Add('Skia', symbols.Filter(lambda s: 'skia/' in s.source_path)) | |
| 43 symbols = g.Add('V8', symbols.Filter( | |
| 44 lambda s: s.source_path.startswith('v8/'))) | |
| 45 | |
| 46 # Next, put non-regex queries, since they're a bit faster. | |
| 47 symbols = g.Add('ICU', symbols.Filter(lambda s: '/icu/' in s.source_path)) | |
| 48 symbols = g.Add('Prefetch', symbols.Filter( | |
| 49 lambda s: 'resource_prefetch' in s.source_path)) | |
| 50 symbols = g.Add('Password Manager', symbols.Filter( | |
| 51 lambda s: 'password_manager' in s.source_path)) | |
| 52 symbols = g.Add('Internals Pages', symbols.Filter( | |
| 53 lambda s: '_internals' in s.source_path)) | |
| 54 symbols = g.Add('Autofill', symbols.WhereSourcePathMatches(r'(?i)autofill')) | |
| 55 symbols = g.Add('WebGL', symbols.WhereMatches(r'(?i)webgl')) | |
| 56 symbols = g.Add('WebBluetooth', symbols.WhereMatches(r'(?i)bluetooth')) | |
| 57 symbols = g.Add('WebUSB', symbols.WhereMatches(r'(?i)webusb|(\b|_)usb(\b|_)')) | |
| 58 symbols = g.Add('WebVR', symbols.WhereMatches( | |
| 59 r'{{_gvr_}}|{{_cwebvr_}}|{{_vr_}}')) | |
| 60 symbols = g.Add('FileSystem', symbols.WhereSourcePathMatches( | |
| 61 r'content/.*/fileapi|WebKit/.*/filesystem')) | |
| 62 symbols = g.Add('WebCrypto', symbols.WhereMatches(r'(?i)webcrypto')) | |
| 63 symbols = g.Add('Printing', symbols.WhereMatches(r'printing')) | |
| 64 symbols = g.Add('Cast', symbols.WhereSourcePathMatches( | |
| 65 r'(?i)(\b|_)cast(\b|_)')) | |
| 66 symbols = g.Add('Media Source', symbols.WhereMatches( | |
| 67 r'(?i)mediasource|blink::.*TrackDefault|blink::.*SourceBuffer')) | |
| 68 | |
| 69 # XSLT must come before libxml. | |
| 70 symbols = g.Add('XSLT', symbols.WhereMatches(r'(?i)xslt')) | |
| 71 symbols = g.Add('libxml', symbols.Filter( | |
| 72 lambda s: 'libxml' in s.source_path)) | |
| 73 | |
| 74 # These have some overlap with above, so need to come afterwards. | |
| 75 blink_syms = symbols.WhereSourcePathMatches(r'\b(blink|WebKit)\b') | |
| 76 symbols = blink_syms.Inverted() | |
| 77 blink_generated = blink_syms.WhereSourceIsGenerated() | |
| 78 g.Add('Blink (generated)', blink_generated) | |
| 79 g.Add('Blink (non-generated)', blink_generated.Inverted()) | |
| 80 | |
| 81 symbols = g.Add('Codecs', symbols.WhereSourcePathMatches( | |
| 82 r'^third_party/(libweb[mp]|libpng|libjpeg_turbo|opus|ffmpeg|libvpx)/')) | |
| 83 symbols = g.Add('Other Third-Party', symbols.Filter( | |
| 84 lambda s: 'third_party' in s.source_path)) | |
| 85 | |
| 86 return g.Finalize(symbols) | |
| 87 | |
| 88 | |
| 89 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
| |
| 90 g = _Grouper() | |
| 91 symbols = symbols.WhereSourceIsGenerated() | |
| 92 symbols = g.Add('Protocol Buffers', symbols.Filter(lambda s: ( | |
| 93 '/protobuf/' in s.object_path or | |
| 94 s.object_path.endswith('.pbzero.o') or | |
| 95 s.object_path.endswith('.pb.o')))) | |
| 96 symbols = g.Add('Mojo', symbols.Filter(lambda s: ( | |
| 97 '.mojom' in s.source_path or # Blink uses .mojom-blink.cc | |
| 98 s.source_path.startswith('mojo/') or | |
| 99 s.name.startswith('mojo::')))) | |
| 100 symbols = g.Add('DevTools', symbols.WhereSourcePathMatches( | |
| 101 r'\b(?:protocol|devtools)\b')) | |
| 102 symbols = g.Add('Blink (bindings)', symbols.Filter(lambda s: ( | |
| 103 'blink/bindings' in s.source_path or | |
| 104 ('WebKit/' in s.object_path and '/bindings/' in s.object_path)))) | |
| 105 symbols = g.Add('Blink (IDL)', symbols.Filter(lambda s: ( | |
| 106 'WebKit/Source/core' in s.object_path))) | |
| 107 symbols = g.Add('Blink (Other)', symbols.Filter(lambda s: ( | |
| 108 'WebKit' in s.object_path or 'blink/' in s.object_path))) | |
| 109 | |
| 110 return g.Finalize(symbols) | |
| OLD | NEW |