OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2014 The Chromium Authors. All rights reserved. | 3 # Copyright 2014 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 136 |
137 browsers = sorted(profiler.GetSupportedBrowsers().keys()) | 137 browsers = sorted(profiler.GetSupportedBrowsers().keys()) |
138 parser.add_option('-b', '--browser', help='Select among installed browsers. ' | 138 parser.add_option('-b', '--browser', help='Select among installed browsers. ' |
139 'One of ' + ', '.join(browsers) + ', "stable" is used by ' | 139 'One of ' + ', '.join(browsers) + ', "stable" is used by ' |
140 'default.', type='choice', choices=browsers, | 140 'default.', type='choice', choices=browsers, |
141 default='stable') | 141 default='stable') |
142 parser.add_option('-v', '--verbose', help='Verbose logging.', | 142 parser.add_option('-v', '--verbose', help='Verbose logging.', |
143 action='store_true') | 143 action='store_true') |
144 parser.add_option('-z', '--compress', help='Compress the resulting trace ' | 144 parser.add_option('-z', '--compress', help='Compress the resulting trace ' |
145 'with gzip. ', action='store_true') | 145 'with gzip. ', action='store_true') |
| 146 parser.add_option('-d', '--device', help='The Android device ID to use.' |
| 147 'If not specified, only 0 or 1 connected devices are ' |
| 148 'supported.', default=None) |
146 return parser | 149 return parser |
147 | 150 |
148 | 151 |
149 def main(): | 152 def main(): |
150 parser = _CreateOptionParser() | 153 parser = _CreateOptionParser() |
151 options, _args = parser.parse_args() | 154 options, _args = parser.parse_args() |
152 if options.trace_cc: | 155 if options.trace_cc: |
153 parser.parse_error("""--trace-cc is deprecated. | 156 parser.parse_error("""--trace-cc is deprecated. |
154 | 157 |
155 For basic jank busting uses, use --trace-frame-viewer | 158 For basic jank busting uses, use --trace-frame-viewer |
156 For detailed study of ubercompositor, pass --trace-ubercompositor. | 159 For detailed study of ubercompositor, pass --trace-ubercompositor. |
157 | 160 |
158 When in doubt, just try out --trace-frame-viewer. | 161 When in doubt, just try out --trace-frame-viewer. |
159 """) | 162 """) |
160 | 163 |
161 if options.verbose: | 164 if options.verbose: |
162 logging.getLogger().setLevel(logging.DEBUG) | 165 logging.getLogger().setLevel(logging.DEBUG) |
163 | 166 |
164 devices = android_commands.GetAttachedDevices() | 167 devices = android_commands.GetAttachedDevices() |
165 if len(devices) != 1: | 168 if not options.device and len(devices) != 1: |
166 parser.error('Exactly 1 device must be attached.') | 169 parser.error('Exactly 1 device must be attached.') |
167 device = device_utils.DeviceUtils(devices[0]) | 170 device = device_utils.DeviceUtils( |
| 171 next((d for d in devices if d == options.device), devices[0])) |
168 package_info = profiler.GetSupportedBrowsers()[options.browser] | 172 package_info = profiler.GetSupportedBrowsers()[options.browser] |
169 | 173 |
170 if options.chrome_categories in ['list', 'help']: | 174 if options.chrome_categories in ['list', 'help']: |
171 ui.PrintMessage('Collecting record categories list...', eol='') | 175 ui.PrintMessage('Collecting record categories list...', eol='') |
172 record_categories = [] | 176 record_categories = [] |
173 disabled_by_default_categories = [] | 177 disabled_by_default_categories = [] |
174 record_categories, disabled_by_default_categories = \ | 178 record_categories, disabled_by_default_categories = \ |
175 chrome_controller.ChromeTracingController.GetCategories( | 179 chrome_controller.ChromeTracingController.GetCategories( |
176 device, package_info) | 180 device, package_info) |
177 | 181 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 enabled_controllers, | 242 enabled_controllers, |
239 options.time if not options.continuous else 0, | 243 options.time if not options.continuous else 0, |
240 output=options.output, | 244 output=options.output, |
241 compress=options.compress, | 245 compress=options.compress, |
242 write_json=options.json) | 246 write_json=options.json) |
243 if options.view: | 247 if options.view: |
244 if sys.platform == 'darwin': | 248 if sys.platform == 'darwin': |
245 os.system('/usr/bin/open %s' % os.path.abspath(result)) | 249 os.system('/usr/bin/open %s' % os.path.abspath(result)) |
246 else: | 250 else: |
247 webbrowser.open(result) | 251 webbrowser.open(result) |
OLD | NEW |