OLD | NEW |
1 # Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """An interactive console for looking analyzing .size files.""" | 5 """An interactive console for looking analyzing .size files.""" |
6 | 6 |
7 import argparse | 7 import argparse |
8 import atexit | 8 import atexit |
9 import code | 9 import code |
10 import contextlib | 10 import contextlib |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } | 77 } |
78 self._lazy_paths = lazy_paths | 78 self._lazy_paths = lazy_paths |
79 self._size_infos = size_infos | 79 self._size_infos = size_infos |
80 | 80 |
81 if len(size_infos) == 1: | 81 if len(size_infos) == 1: |
82 self._variables['size_info'] = size_infos[0] | 82 self._variables['size_info'] = size_infos[0] |
83 else: | 83 else: |
84 for i, size_info in enumerate(size_infos): | 84 for i, size_info in enumerate(size_infos): |
85 self._variables['size_info%d' % (i + 1)] = size_info | 85 self._variables['size_info%d' % (i + 1)] = size_info |
86 | 86 |
87 def _DiffFunc(self, before=None, after=None, cluster=True): | 87 def _DiffFunc(self, before=None, after=None, cluster=True, sort=True): |
88 """Diffs two SizeInfo objects. Returns a SizeInfoDiff. | 88 """Diffs two SizeInfo objects. Returns a SizeInfoDiff. |
89 | 89 |
90 Args: | 90 Args: |
91 before: Defaults to first size_infos[0]. | 91 before: Defaults to first size_infos[0]. |
92 after: Defaults to second size_infos[1]. | 92 after: Defaults to second size_infos[1]. |
93 cluster: When True, calls SymbolGroup.Cluster() after diffing. This | 93 cluster: When True (default), calls SymbolGroup.Cluster() after diffing. |
94 generally reduces noise. | 94 Generally reduces noise. |
| 95 sort: When True (default), calls SymbolGroup.Sorted() after diffing. |
95 """ | 96 """ |
96 before = before if before is not None else self._size_infos[0] | 97 before = before if before is not None else self._size_infos[0] |
97 after = after if after is not None else self._size_infos[1] | 98 after = after if after is not None else self._size_infos[1] |
98 return diff.Diff(before, after, cluster=cluster) | 99 ret = diff.Diff(before, after) |
| 100 if cluster: |
| 101 ret.symbols = ret.symbols.Cluster() |
| 102 if sort: |
| 103 ret.symbols = ret.symbols.Sorted() |
| 104 return ret |
99 | 105 |
100 def _PrintFunc(self, obj=None, verbose=False, recursive=False, use_pager=None, | 106 def _PrintFunc(self, obj=None, verbose=False, recursive=False, use_pager=None, |
101 to_file=None): | 107 to_file=None): |
102 """Prints out the given Symbol / SymbolGroup / SymbolDiff / SizeInfo. | 108 """Prints out the given Symbol / SymbolGroup / SymbolDiff / SizeInfo. |
103 | 109 |
104 Args: | 110 Args: |
105 obj: The object to be printed. Defaults to size_infos[-1]. | 111 obj: The object to be printed. Defaults to size_infos[-1]. |
106 verbose: Show more detailed output. | 112 verbose: Show more detailed output. |
107 recursive: Print children of nested SymbolGroups. | 113 recursive: Print children of nested SymbolGroups. |
108 use_pager: Pipe output through `less`. Ignored when |obj| is a Symbol. | 114 use_pager: Pipe output through `less`. Ignored when |obj| is a Symbol. |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 output_directory=args.output_directory, | 277 output_directory=args.output_directory, |
272 any_path_within_output_directory=args.inputs[0]) | 278 any_path_within_output_directory=args.inputs[0]) |
273 session = _Session(size_infos, lazy_paths) | 279 session = _Session(size_infos, lazy_paths) |
274 | 280 |
275 if args.query: | 281 if args.query: |
276 logging.info('Running query from command-line.') | 282 logging.info('Running query from command-line.') |
277 session.Eval(args.query) | 283 session.Eval(args.query) |
278 else: | 284 else: |
279 logging.info('Entering interactive console.') | 285 logging.info('Entering interactive console.') |
280 session.GoInteractive() | 286 session.GoInteractive() |
OLD | NEW |