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 22 matching lines...) Expand all Loading... |
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 parser.add_option('--url', help='URL to visit on startup. Default: ' |
37 'https://www.google.com. An empty URL launches Chrome with' | 37 'https://www.google.com. An empty URL launches Chrome with' |
38 ' a MAIN action instead of VIEW.', | 38 ' a MAIN action instead of VIEW.', |
39 default='https://www.google.com', metavar='URL') | 39 default='https://www.google.com', metavar='URL') |
40 parser.add_option('--cold', help='Flush the OS page cache before starting the' | 40 parser.add_option('--cold', help='Flush the OS page cache before starting the' |
41 ' browser. Note that this require a device with root ' | 41 ' browser. Note that this require a device with root ' |
42 'access.', default=False, action='store_true') | 42 'access.', default=False, action='store_true') |
43 parser.add_option_group(flags.AtraceOptions(parser)) | 43 parser.add_option_group(atrace_tracing_agent.add_options(parser)) |
44 parser.add_option_group(flags.OutputOptions(parser)) | 44 parser.add_option_group(flags.OutputOptions(parser)) |
45 | 45 |
46 browsers = sorted(profiler.GetSupportedBrowsers().keys()) | 46 browsers = sorted(profiler.GetSupportedBrowsers().keys()) |
47 parser.add_option('-b', '--browser', help='Select among installed browsers. ' | 47 parser.add_option('-b', '--browser', help='Select among installed browsers. ' |
48 'One of ' + ', '.join(browsers) + ', "stable" is used by ' | 48 'One of ' + ', '.join(browsers) + ', "stable" is used by ' |
49 'default.', type='choice', choices=browsers, | 49 'default.', type='choice', choices=browsers, |
50 default='stable') | 50 default='stable') |
51 parser.add_option('-v', '--verbose', help='Verbose logging.', | 51 parser.add_option('-v', '--verbose', help='Verbose logging.', |
52 action='store_true') | 52 action='store_true') |
53 parser.add_option('-z', '--compress', help='Compress the resulting trace ' | 53 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 | 82 # Enable the atrace and chrome agents. The atrace agent should go |
83 # first because otherwise the resulting traces miss early atrace data. | 83 # first because otherwise the resulting traces miss early atrace data. |
84 if atrace_categories: | 84 if atrace_categories: |
85 enabled_agents.append(atrace_tracing_agent.AtraceAgent( | 85 enabled_agents.append(atrace_tracing_agent.AtraceAgent( |
86 device, atrace_categories, False)) | 86 device, atrace_categories, False)) |
87 enabled_agents.append( | 87 enabled_agents.append( |
88 chrome_startup_tracing_agent.ChromeStartupTracingAgent( | 88 chrome_startup_tracing_agent.ChromeStartupTracingAgent( |
89 device, package_info, options.cold, options.url)) | 89 device, package_info, options.cold, options.url)) |
90 if options.output: | 90 if options.output: |
91 options.output = os.path.expanduser(options.output) | 91 options.output = os.path.expanduser(options.output) |
92 result = profiler.CaptureProfile(enabled_agents, | 92 result = profiler.CaptureProfile(options, |
| 93 enabled_agents, |
93 options.time, | 94 options.time, |
94 output=options.output, | 95 output=options.output, |
95 compress=options.compress, | 96 compress=options.compress, |
96 write_json=options.json) | 97 write_json=options.json) |
97 if options.view: | 98 if options.view: |
98 if sys.platform == 'darwin': | 99 if sys.platform == 'darwin': |
99 os.system('/usr/bin/open %s' % os.path.abspath(result)) | 100 os.system('/usr/bin/open %s' % os.path.abspath(result)) |
100 else: | 101 else: |
101 webbrowser.open(result) | 102 webbrowser.open(result) |
102 | 103 |
103 | 104 |
104 if __name__ == '__main__': | 105 if __name__ == '__main__': |
105 sys.exit(main()) | 106 sys.exit(main()) |
OLD | NEW |