| 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..03edd139f06d7d9f31393d9371896f79da1d7522
|
| --- /dev/null
|
| +++ b/tools/binary_size/libsupersize/precanned_queries.py
|
| @@ -0,0 +1,100 @@
|
| +# 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.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/')))
|
| + symbols = g.Add('Blink (bindings)', symbols.Filter(
|
| + lambda s: 'blink/bindings' in s.source_path))
|
| + symbols = g.Add('Blink (other)', symbols.WhereSourcePathMatches(
|
| + r'\b(blink|WebKit)\b'))
|
| +
|
| + # 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('Codecs', symbols.WhereSourcePathMatches(
|
| + r'^third_party/(libweb[mp]|libpng|libjpeg_turbo|opus|ffmpeg|libvpx|)'))
|
| + 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))
|
| +
|
| + return g.Finalize(symbols)
|
| +
|
| +
|
| +def CategorizeGenerated(symbols):
|
| + g = _Grouper()
|
| + proto_filter = lambda s: (
|
| + '/protobuf/' in s.object_path or s.object_path.endswith('.pb.o'))
|
| + mojo_filter = lambda s: (
|
| + s.source_path.endswith('.mojom.cc') or
|
| + s.source_path.startswith('mojo/') or
|
| + s.name.startswith('mojo::'))
|
| + symbols = g.Add('Protocol Buffers', symbols.Filter(proto_filter))
|
| + symbols = g.Add('Mojo', symbols.Filter(mojo_filter))
|
| + symbols = g.Add('Other Generated', symbols.WhereSourceIsGenerated())
|
| +
|
| + return g.Finalize(symbols)
|
| +
|
| +
|
| +def TemplateStats(symbols):
|
| + # TODO(agrieve): Stats about stl as well as general templates.
|
| + raise Exception('Not yet implemented.')
|
|
|