Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: tools/binary_size/libsupersize/main.py

Issue 2864063002: Supersize: Chrome-specific breakdowns, console tweaks (Closed)
Patch Set: review tweaks Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2017 The Chromium Authors. All rights reserved. 2 # Copyright 2017 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Collect, archive, and analyze Chrome's binary size.""" 6 """Collect, archive, and analyze Chrome's binary size."""
7 7
8 import argparse 8 import argparse
9 import atexit 9 import atexit
10 import collections 10 import collections
(...skipping 30 matching lines...) Expand all
41 def AddArguments(parser): 41 def AddArguments(parser):
42 parser.add_argument('before', help='Before-patch .size file.') 42 parser.add_argument('before', help='Before-patch .size file.')
43 parser.add_argument('after', help='After-patch .size file.') 43 parser.add_argument('after', help='After-patch .size file.')
44 parser.add_argument('--all', action='store_true', help='Verbose diff') 44 parser.add_argument('--all', action='store_true', help='Verbose diff')
45 45
46 @staticmethod 46 @staticmethod
47 def Run(args, parser): 47 def Run(args, parser):
48 args.output_directory = None 48 args.output_directory = None
49 args.tool_prefix = None 49 args.tool_prefix = None
50 args.inputs = [args.before, args.after] 50 args.inputs = [args.before, args.after]
51 args.query = ('Print(Diff(size_info1, size_info2), verbose=%s)' % 51 args.query = ('Print(Diff(), verbose=%s)' % bool(args.all))
52 bool(args.all))
53 console.Run(args, parser) 52 console.Run(args, parser)
54 53
55 54
56 def main(): 55 def main():
57 parser = argparse.ArgumentParser(description=__doc__) 56 parser = argparse.ArgumentParser(description=__doc__)
58 sub_parsers = parser.add_subparsers() 57 sub_parsers = parser.add_subparsers()
59 actions = collections.OrderedDict() 58 actions = collections.OrderedDict()
60 actions['archive'] = (archive, 'Create a .size file') 59 actions['archive'] = (archive, 'Create a .size file')
61 actions['html_report'] = ( 60 actions['html_report'] = (
62 html_report, 'Create a stand-alone html report from a .size file.') 61 html_report, 'Create a stand-alone html report from a .size file.')
63 actions['console'] = ( 62 actions['console'] = (
64 console, 63 console,
65 'Starts an interactive Python console for analyzing .size files.') 64 'Starts an interactive Python console for analyzing .size files.')
66 actions['diff'] = ( 65 actions['diff'] = (
67 _DiffAction(), 66 _DiffAction(),
68 'Shorthand for console --query "Print(Diff(size_info1, size_info2))"') 67 'Shorthand for console --query "Print(Diff())"')
69 68
70 for name, tup in actions.iteritems(): 69 for name, tup in actions.iteritems():
71 sub_parser = sub_parsers.add_parser(name, help=tup[1]) 70 sub_parser = sub_parsers.add_parser(name, help=tup[1])
72 _AddCommonArguments(sub_parser) 71 _AddCommonArguments(sub_parser)
73 tup[0].AddArguments(sub_parser) 72 tup[0].AddArguments(sub_parser)
74 sub_parser.set_defaults(func=tup[0].Run) 73 sub_parser.set_defaults(func=tup[0].Run)
75 74
76 if len(sys.argv) == 1: 75 if len(sys.argv) == 1:
77 parser.print_help() 76 parser.print_help()
78 sys.exit(1) 77 sys.exit(1)
(...skipping 15 matching lines...) Expand all
94 logging.warning('This script runs more than 2x faster if you install pypy.') 93 logging.warning('This script runs more than 2x faster if you install pypy.')
95 94
96 if logging.getLogger().isEnabledFor(logging.DEBUG): 95 if logging.getLogger().isEnabledFor(logging.DEBUG):
97 atexit.register(_LogPeakRamUsage) 96 atexit.register(_LogPeakRamUsage)
98 97
99 args.func(args, parser) 98 args.func(args, parser)
100 99
101 100
102 if __name__ == '__main__': 101 if __name__ == '__main__':
103 main() 102 main()
OLDNEW
« no previous file with comments | « tools/binary_size/libsupersize/integration_test.py ('k') | tools/binary_size/libsupersize/models.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698