OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2015 The Chromium Authors. All rights reserved. | 3 # Copyright 2015 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 import logging | 7 import logging |
8 import optparse | 8 import optparse |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 15 matching lines...) Expand all Loading... | |
26 from devil.android import device_utils | 26 from devil.android import device_utils |
27 | 27 |
28 | 28 |
29 def _CreateOptionParser(): | 29 def _CreateOptionParser(): |
30 parser = optparse.OptionParser(description='Record about://tracing profiles ' | 30 parser = optparse.OptionParser(description='Record about://tracing profiles ' |
31 'from Android browsers startup, combined with ' | 31 'from Android browsers startup, combined with ' |
32 'Android systrace. See http://dev.chromium.org' | 32 'Android systrace. See http://dev.chromium.org' |
33 '/developers/how-tos/trace-event-profiling-' | 33 '/developers/how-tos/trace-event-profiling-' |
34 'tool for detailed instructions for ' | 34 'tool for detailed instructions for ' |
35 'profiling.') | 35 'profiling.') |
36 parser.add_option('--url', help='URL to visit on startup. Default: ' | 36 |
37 'https://www.google.com. An empty URL launches Chrome with' | 37 parser.add_option_group(chrome_startup_tracing_agent.add_options(parser)) |
Zhen Wang
2016/08/29 21:00:26
Move this after all parser.add_option() function c
washingtonp
2016/08/29 21:13:16
Done.
| |
38 ' a MAIN action instead of VIEW.', | 38 parser.add_option_group(atrace_tracing_agent.add_options(parser)) |
39 default='https://www.google.com', metavar='URL') | |
40 parser.add_option('--cold', help='Flush the OS page cache before starting the' | |
41 ' browser. Note that this require a device with root ' | |
42 'access.', default=False, action='store_true') | |
43 parser.add_option_group(flags.AtraceOptions(parser)) | |
44 parser.add_option_group(flags.OutputOptions(parser)) | 39 parser.add_option_group(flags.OutputOptions(parser)) |
45 | 40 |
46 browsers = sorted(profiler.GetSupportedBrowsers().keys()) | 41 browsers = sorted(profiler.GetSupportedBrowsers().keys()) |
47 parser.add_option('-b', '--browser', help='Select among installed browsers. ' | 42 parser.add_option('-b', '--browser', help='Select among installed browsers. ' |
48 'One of ' + ', '.join(browsers) + ', "stable" is used by ' | 43 'One of ' + ', '.join(browsers) + ', "stable" is used by ' |
49 'default.', type='choice', choices=browsers, | 44 'default.', type='choice', choices=browsers, |
50 default='stable') | 45 default='stable') |
51 parser.add_option('-v', '--verbose', help='Verbose logging.', | 46 parser.add_option('-v', '--verbose', help='Verbose logging.', |
52 action='store_true') | 47 action='store_true') |
53 parser.add_option('-z', '--compress', help='Compress the resulting trace ' | 48 parser.add_option('-z', '--compress', help='Compress the resulting trace ' |
(...skipping 28 matching lines...) Expand all Loading... | |
82 # Enable the atrace and chrome agents. The atrace agent should go | 77 # Enable the atrace and chrome agents. The atrace agent should go |
83 # first because otherwise the resulting traces miss early atrace data. | 78 # first because otherwise the resulting traces miss early atrace data. |
84 if atrace_categories: | 79 if atrace_categories: |
85 enabled_agents.append(atrace_tracing_agent.AtraceAgent( | 80 enabled_agents.append(atrace_tracing_agent.AtraceAgent( |
86 device, atrace_categories, False)) | 81 device, atrace_categories, False)) |
87 enabled_agents.append( | 82 enabled_agents.append( |
88 chrome_startup_tracing_agent.ChromeStartupTracingAgent( | 83 chrome_startup_tracing_agent.ChromeStartupTracingAgent( |
89 device, package_info, options.cold, options.url)) | 84 device, package_info, options.cold, options.url)) |
90 if options.output: | 85 if options.output: |
91 options.output = os.path.expanduser(options.output) | 86 options.output = os.path.expanduser(options.output) |
92 result = profiler.CaptureProfile(enabled_agents, | 87 result = profiler.CaptureProfile(options, |
88 enabled_agents, | |
93 options.time, | 89 options.time, |
94 output=options.output, | 90 output=options.output, |
95 compress=options.compress, | 91 compress=options.compress, |
96 write_json=options.json) | 92 write_json=options.json) |
97 if options.view: | 93 if options.view: |
98 if sys.platform == 'darwin': | 94 if sys.platform == 'darwin': |
99 os.system('/usr/bin/open %s' % os.path.abspath(result)) | 95 os.system('/usr/bin/open %s' % os.path.abspath(result)) |
100 else: | 96 else: |
101 webbrowser.open(result) | 97 webbrowser.open(result) |
102 | 98 |
103 | 99 |
104 if __name__ == '__main__': | 100 if __name__ == '__main__': |
105 sys.exit(main()) | 101 sys.exit(main()) |
OLD | NEW |