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 json | 8 import json |
9 import logging | 9 import logging |
10 import optparse | 10 import optparse |
(...skipping 13 matching lines...) Expand all Loading... | |
24 from pylib import constants | 24 from pylib import constants |
25 from pylib import pexpect | 25 from pylib import pexpect |
26 from pylib.device import device_utils | 26 from pylib.device import device_utils |
27 | 27 |
28 _TRACE_VIEWER_ROOT = os.path.join(constants.DIR_SOURCE_ROOT, | 28 _TRACE_VIEWER_ROOT = os.path.join(constants.DIR_SOURCE_ROOT, |
29 'third_party', 'trace-viewer') | 29 'third_party', 'trace-viewer') |
30 sys.path.append(_TRACE_VIEWER_ROOT) | 30 sys.path.append(_TRACE_VIEWER_ROOT) |
31 from trace_viewer.build import trace2html # pylint: disable=F0401 | 31 from trace_viewer.build import trace2html # pylint: disable=F0401 |
32 | 32 |
33 _DEFAULT_CHROME_CATEGORIES = '_DEFAULT_CHROME_CATEGORIES' | 33 _DEFAULT_CHROME_CATEGORIES = '_DEFAULT_CHROME_CATEGORIES' |
34 | 34 _HEAP_PROFILE_MMAP = 'heapprof.mmap' |
Sami
2014/05/19 16:00:10
nit: could you call this _HEAP_PROFILE_MMAP_PROPER
JungJik
2014/05/19 16:35:36
sure!
| |
35 | 35 |
36 def _GetTraceTimestamp(): | 36 def _GetTraceTimestamp(): |
37 return time.strftime('%Y-%m-%d-%H%M%S', time.localtime()) | 37 return time.strftime('%Y-%m-%d-%H%M%S', time.localtime()) |
38 | 38 |
39 | 39 |
40 class ChromeTracingController(object): | 40 class ChromeTracingController(object): |
41 def __init__(self, device, package_info, categories, ring_buffer): | 41 def __init__(self, device, package_info, categories, ring_buffer): |
42 self._device = device | 42 self._device = device |
43 self._package_info = package_info | 43 self._package_info = package_info |
44 self._categories = categories | 44 self._categories = categories |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 def _ComputeChromeCategories(options): | 302 def _ComputeChromeCategories(options): |
303 categories = [] | 303 categories = [] |
304 if options.trace_frame_viewer: | 304 if options.trace_frame_viewer: |
305 categories.append('disabled-by-default-cc.debug') | 305 categories.append('disabled-by-default-cc.debug') |
306 if options.trace_ubercompositor: | 306 if options.trace_ubercompositor: |
307 categories.append('disabled-by-default-cc.debug*') | 307 categories.append('disabled-by-default-cc.debug*') |
308 if options.trace_gpu: | 308 if options.trace_gpu: |
309 categories.append('disabled-by-default-gpu.debug*') | 309 categories.append('disabled-by-default-gpu.debug*') |
310 if options.trace_flow: | 310 if options.trace_flow: |
311 categories.append('disabled-by-default-toplevel.flow') | 311 categories.append('disabled-by-default-toplevel.flow') |
312 if options.trace_memory: | |
313 categories.append('disabled-by-default-memory') | |
312 if options.chrome_categories: | 314 if options.chrome_categories: |
313 categories += options.chrome_categories.split(',') | 315 categories += options.chrome_categories.split(',') |
314 return categories | 316 return categories |
315 | 317 |
316 | 318 |
317 def _ComputeSystraceCategories(options): | 319 def _ComputeSystraceCategories(options): |
318 if not options.systrace_categories: | 320 if not options.systrace_categories: |
319 return [] | 321 return [] |
320 return options.systrace_categories.split(',') | 322 return options.systrace_categories.split(',') |
321 | 323 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
364 categories.add_option('--trace-frame-viewer', | 366 categories.add_option('--trace-frame-viewer', |
365 help='Enable enough trace categories for ' | 367 help='Enable enough trace categories for ' |
366 'compositor frame viewing.', action='store_true') | 368 'compositor frame viewing.', action='store_true') |
367 categories.add_option('--trace-ubercompositor', | 369 categories.add_option('--trace-ubercompositor', |
368 help='Enable enough trace categories for ' | 370 help='Enable enough trace categories for ' |
369 'ubercompositor frame data.', action='store_true') | 371 'ubercompositor frame data.', action='store_true') |
370 categories.add_option('--trace-gpu', help='Enable extra trace categories for ' | 372 categories.add_option('--trace-gpu', help='Enable extra trace categories for ' |
371 'GPU data.', action='store_true') | 373 'GPU data.', action='store_true') |
372 categories.add_option('--trace-flow', help='Enable extra trace categories ' | 374 categories.add_option('--trace-flow', help='Enable extra trace categories ' |
373 'for IPC message flows.', action='store_true') | 375 'for IPC message flows.', action='store_true') |
376 categories.add_option('--trace-memory', help='Enable extra trace categories ' | |
377 'for memory profile. (tcmalloc required)', | |
378 action='store_true') | |
374 parser.add_option_group(categories) | 379 parser.add_option_group(categories) |
375 | 380 |
376 output_options = optparse.OptionGroup(parser, 'Output options') | 381 output_options = optparse.OptionGroup(parser, 'Output options') |
377 output_options.add_option('-o', '--output', help='Save trace output to file.') | 382 output_options.add_option('-o', '--output', help='Save trace output to file.') |
378 output_options.add_option('--json', help='Save trace as raw JSON instead of ' | 383 output_options.add_option('--json', help='Save trace as raw JSON instead of ' |
379 'HTML.', action='store_true') | 384 'HTML.', action='store_true') |
380 output_options.add_option('--view', help='Open resulting trace file in a ' | 385 output_options.add_option('--view', help='Open resulting trace file in a ' |
381 'browser.', action='store_true') | 386 'browser.', action='store_true') |
382 parser.add_option_group(output_options) | 387 parser.add_option_group(output_options) |
383 | 388 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
428 return 0 | 433 return 0 |
429 | 434 |
430 if options.systrace_categories in ['list', 'help']: | 435 if options.systrace_categories in ['list', 'help']: |
431 _PrintMessage('\n'.join(SystraceController.GetCategories(device))) | 436 _PrintMessage('\n'.join(SystraceController.GetCategories(device))) |
432 return 0 | 437 return 0 |
433 | 438 |
434 if not options.time and not options.continuous: | 439 if not options.time and not options.continuous: |
435 _PrintMessage('Time interval or continuous tracing should be specified.') | 440 _PrintMessage('Time interval or continuous tracing should be specified.') |
436 return 1 | 441 return 1 |
437 | 442 |
443 system_properties = device.old_interface.system_properties | |
444 if options.trace_memory: | |
445 if not device.old_interface.IsRootEnabled(): | |
446 device.old_interface.EnableAdbRoot() | |
Sami
2014/05/19 16:00:10
You can just call EnableAdbRoot() unconditionally
JungJik
2014/05/19 16:35:36
thanks for your comment.
| |
447 system_properties[_HEAP_PROFILE_MMAP] = 1 | |
448 else: | |
449 system_properties[_HEAP_PROFILE_MMAP] = 0 | |
Sami
2014/05/19 11:39:49
Should we reset this property after tracing? Are t
JungJik
2014/05/19 12:08:10
Thanks for your comment.
I've just checked the co
Sami
2014/05/19 16:00:10
Thanks for checking. I was thinking more about the
JungJik
2014/05/19 16:35:36
how about reset after pulling the trace file, then
| |
450 | |
438 chrome_categories = _ComputeChromeCategories(options) | 451 chrome_categories = _ComputeChromeCategories(options) |
439 systrace_categories = _ComputeSystraceCategories(options) | 452 systrace_categories = _ComputeSystraceCategories(options) |
440 | 453 |
441 if chrome_categories and 'webview' in systrace_categories: | 454 if chrome_categories and 'webview' in systrace_categories: |
442 logging.warning('Using the "webview" category in systrace together with ' | 455 logging.warning('Using the "webview" category in systrace together with ' |
443 'Chrome tracing results in duplicate trace events.') | 456 'Chrome tracing results in duplicate trace events.') |
444 | 457 |
445 controllers = [] | 458 controllers = [] |
446 if chrome_categories: | 459 if chrome_categories: |
447 controllers.append(ChromeTracingController(device, | 460 controllers.append(ChromeTracingController(device, |
(...skipping 18 matching lines...) Expand all Loading... | |
466 options.json) | 479 options.json) |
467 if options.view: | 480 if options.view: |
468 if sys.platform == 'darwin': | 481 if sys.platform == 'darwin': |
469 os.system('/usr/bin/open %s' % os.path.abspath(result)) | 482 os.system('/usr/bin/open %s' % os.path.abspath(result)) |
470 else: | 483 else: |
471 webbrowser.open(result) | 484 webbrowser.open(result) |
472 | 485 |
473 | 486 |
474 if __name__ == '__main__': | 487 if __name__ == '__main__': |
475 sys.exit(main()) | 488 sys.exit(main()) |
OLD | NEW |