OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 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 gzip | 7 import gzip |
8 import logging | 8 import logging |
9 import optparse | 9 import optparse |
10 import os | 10 import os |
11 import re | 11 import re |
12 import sys | 12 import sys |
13 import threading | 13 import threading |
14 import time | 14 import time |
15 import zipfile | 15 import zipfile |
16 import zlib | 16 import zlib |
17 | 17 |
18 from pylib import android_commands | 18 from pylib import android_commands |
19 from pylib import cmd_helper | 19 from pylib import cmd_helper |
20 from pylib import constants | 20 from pylib import constants |
21 from pylib import pexpect | 21 from pylib import pexpect |
22 | 22 |
23 | 23 |
24 _DEFAULT_CHROME_CATEGORIES = '_DEFAULT_CHROME_CATEGORIES' | |
Sami
2013/10/16 09:43:34
Instead of sending this string to Chrome, could we
Xianzhu
2013/10/16 16:47:48
I had thought so but later found when --trace-cc o
| |
25 | |
26 | |
24 def _GetTraceTimestamp(): | 27 def _GetTraceTimestamp(): |
25 return time.strftime('%Y-%m-%d-%H%M%S', time.localtime()) | 28 return time.strftime('%Y-%m-%d-%H%M%S', time.localtime()) |
26 | 29 |
27 | 30 |
28 class ChromeTracingController(object): | 31 class ChromeTracingController(object): |
29 def __init__(self, adb, package_info, categories, ring_buffer): | 32 def __init__(self, adb, package_info, categories, ring_buffer): |
30 self._adb = adb | 33 self._adb = adb |
31 self._package_info = package_info | 34 self._package_info = package_info |
32 self._categories = categories | 35 self._categories = categories |
33 self._ring_buffer = ring_buffer | 36 self._ring_buffer = ring_buffer |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
280 cont_options = optparse.OptionGroup(parser, 'Continuous tracing') | 283 cont_options = optparse.OptionGroup(parser, 'Continuous tracing') |
281 cont_options.add_option('--continuous', help='Profile continuously until ' | 284 cont_options.add_option('--continuous', help='Profile continuously until ' |
282 'stopped.', action='store_true') | 285 'stopped.', action='store_true') |
283 cont_options.add_option('--ring-buffer', help='Use the trace buffer as a ' | 286 cont_options.add_option('--ring-buffer', help='Use the trace buffer as a ' |
284 'ring buffer and save its contents when stopping ' | 287 'ring buffer and save its contents when stopping ' |
285 'instead of appending events into one long trace.', | 288 'instead of appending events into one long trace.', |
286 action='store_true') | 289 action='store_true') |
287 parser.add_option_group(cont_options) | 290 parser.add_option_group(cont_options) |
288 | 291 |
289 categories = optparse.OptionGroup(parser, 'Trace categories') | 292 categories = optparse.OptionGroup(parser, 'Trace categories') |
290 categories.add_option('-c', '--categories', help='Select categories to trace ' | 293 categories.add_option('-c', '--categories', help='Select Chrome tracing ' |
291 'with comma-delimited wildcards, e.g., ' | 294 'categories with comma-delimited wildcards, ' |
292 '"*", "cat1*,-cat1a". Default is "*".', default='*', | 295 'e.g., "*", "cat1*,-cat1a". Omit this option to trace ' |
293 dest='chrome_categories') | 296 'Chrome\'s default categories. Chrome tracing can be ' |
297 'disabled with "--categories=\'\'".', | |
298 metavar='CHROME_CATEGORIES', dest='chrome_categories', | |
299 default=_DEFAULT_CHROME_CATEGORIES) | |
294 categories.add_option('-s', '--systrace', help='Capture a systrace with the ' | 300 categories.add_option('-s', '--systrace', help='Capture a systrace with the ' |
295 'chosen comma-delimited systrace categories. You can ' | 301 'chosen comma-delimited systrace categories. You can ' |
296 'also capture a combined Chrome + systrace by enabling ' | 302 'also capture a combined Chrome + systrace by enabling ' |
297 'both types of categories. Use "list" to see the ' | 303 'both types of categories. Use "list" to see the ' |
298 'available categories.', metavar='SYS_CATEGORIES', | 304 'available categories. Systrace is disabled by ' |
305 'default.', metavar='SYS_CATEGORIES', | |
299 dest='systrace_categories', default='') | 306 dest='systrace_categories', default='') |
300 categories.add_option('--trace-cc', help='Enable extra trace categories for ' | 307 categories.add_option('--trace-cc', help='Enable extra trace categories for ' |
301 'compositor frame viewer data.', action='store_true') | 308 'compositor frame viewer data.', action='store_true') |
302 categories.add_option('--trace-gpu', help='Enable extra trace categories for ' | 309 categories.add_option('--trace-gpu', help='Enable extra trace categories for ' |
303 'GPU data.', action='store_true') | 310 'GPU data.', action='store_true') |
304 parser.add_option_group(categories) | 311 parser.add_option_group(categories) |
305 | 312 |
306 parser.add_option('-o', '--output', help='Save profile output to file.') | 313 parser.add_option('-o', '--output', help='Save profile output to file.') |
307 browsers = sorted(_GetSupportedBrowsers().keys()) | 314 browsers = sorted(_GetSupportedBrowsers().keys()) |
308 parser.add_option('-b', '--browser', help='Select among installed browsers. ' | 315 parser.add_option('-b', '--browser', help='Select among installed browsers. ' |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
351 return 1 | 358 return 1 |
352 | 359 |
353 _CaptureAndPullTrace(controllers, | 360 _CaptureAndPullTrace(controllers, |
354 options.time if not options.continuous else 0, | 361 options.time if not options.continuous else 0, |
355 options.output, | 362 options.output, |
356 options.compress) | 363 options.compress) |
357 | 364 |
358 | 365 |
359 if __name__ == '__main__': | 366 if __name__ == '__main__': |
360 sys.exit(main()) | 367 sys.exit(main()) |
OLD | NEW |