Add --trace-memory option for tracing heap memory
desktop-chromium can trace memory status in about://tracing. as same as desktop, this patch enables android to use disabled-by-default-memory option in adb_profile_chrome script. BUG=None Review URL: https://codereview.chromium.org/291723002 git-svn-id: http://src.chromium.org/svn/trunk/src/build@273031 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
Родитель
64b9ab5a05
Коммит
e86e985bbf
|
@ -11,9 +11,11 @@ from chrome_profiler import controllers
|
|||
|
||||
from pylib import pexpect
|
||||
|
||||
_HEAP_PROFILE_MMAP_PROPERTY = 'heapprof.mmap'
|
||||
|
||||
class ChromeTracingController(controllers.BaseController):
|
||||
def __init__(self, device, package_info, categories, ring_buffer):
|
||||
def __init__(self, device, package_info,
|
||||
categories, ring_buffer, trace_memory=False):
|
||||
controllers.BaseController.__init__(self)
|
||||
self._device = device
|
||||
self._package_info = package_info
|
||||
|
@ -21,6 +23,7 @@ class ChromeTracingController(controllers.BaseController):
|
|||
self._ring_buffer = ring_buffer
|
||||
self._trace_file = None
|
||||
self._trace_interval = None
|
||||
self._trace_memory = trace_memory
|
||||
self._trace_start_re = \
|
||||
re.compile(r'Logging performance trace to file')
|
||||
self._trace_finish_re = \
|
||||
|
@ -59,6 +62,12 @@ class ChromeTracingController(controllers.BaseController):
|
|||
self._package_info.package, 'GPU_PROFILER_START',
|
||||
'-e categories "%s"' % ','.join(self._categories),
|
||||
'-e continuous' if self._ring_buffer else '')
|
||||
|
||||
if self._trace_memory:
|
||||
self._device.old_interface.EnableAdbRoot()
|
||||
self._device.old_interface.system_properties \
|
||||
[_HEAP_PROFILE_MMAP_PROPERTY] = 1
|
||||
|
||||
# Chrome logs two different messages related to tracing:
|
||||
#
|
||||
# 1. "Logging performance trace to file"
|
||||
|
@ -79,6 +88,9 @@ class ChromeTracingController(controllers.BaseController):
|
|||
'GPU_PROFILER_STOP')
|
||||
self._trace_file = self._device.old_interface.WaitForLogMatch(
|
||||
self._trace_finish_re, None, timeout=120).group(1)
|
||||
if self._trace_memory:
|
||||
self._device.old_interface.system_properties \
|
||||
[_HEAP_PROFILE_MMAP_PROPERTY] = 0
|
||||
|
||||
def PullTrace(self):
|
||||
# Wait a bit for the browser to finish writing the trace file.
|
||||
|
|
|
@ -32,6 +32,8 @@ def _ComputeChromeCategories(options):
|
|||
categories.append('disabled-by-default-gpu.debug*')
|
||||
if options.trace_flow:
|
||||
categories.append('disabled-by-default-toplevel.flow')
|
||||
if options.trace_memory:
|
||||
categories.append('disabled-by-default-memory')
|
||||
if options.chrome_categories:
|
||||
categories += options.chrome_categories.split(',')
|
||||
return categories
|
||||
|
@ -87,6 +89,9 @@ def _CreateOptionParser():
|
|||
'for GPU data.', action='store_true')
|
||||
chrome_opts.add_option('--trace-flow', help='Enable extra trace categories '
|
||||
'for IPC message flows.', action='store_true')
|
||||
chrome_opts.add_option('--trace-memory', help='Enable extra trace categories '
|
||||
'for memory profile. (tcmalloc required)',
|
||||
action='store_true')
|
||||
parser.add_option_group(chrome_opts)
|
||||
|
||||
systrace_opts = optparse.OptionGroup(parser, 'Systrace tracing options')
|
||||
|
@ -181,7 +186,8 @@ When in doubt, just try out --trace-frame-viewer.
|
|||
chrome_controller.ChromeTracingController(device,
|
||||
package_info,
|
||||
chrome_categories,
|
||||
options.ring_buffer))
|
||||
options.ring_buffer,
|
||||
options.trace_memory))
|
||||
if systrace_categories:
|
||||
enabled_controllers.append(
|
||||
systrace_controller.SystraceController(device,
|
||||
|
|
Загрузка…
Ссылка в новой задаче