diff options
author | jbudorick <jbudorick@chromium.org> | 2015-02-03 11:38:38 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-03 19:39:29 +0000 |
commit | 7103545f9756c669cf3d29085658f9fb159a0d18 (patch) | |
tree | 9081504a371e5b4596a14ac7db2e7d83f95f3d05 /tools/profile_chrome | |
parent | ff49cf31bc0e2c4c56e330a978a9f9599d75c6ab (diff) | |
download | chromium_src-7103545f9756c669cf3d29085658f9fb159a0d18.zip chromium_src-7103545f9756c669cf3d29085658f9fb159a0d18.tar.gz chromium_src-7103545f9756c669cf3d29085658f9fb159a0d18.tar.bz2 |
[Android] Add LogcatMonitor.
LogcatMonitor provides the same functionality as
AndroidCommands.WaitForLogMatch and the associated functions.
BUG=267773
Review URL: https://codereview.chromium.org/896503002
Cr-Commit-Position: refs/heads/master@{#314384}
Diffstat (limited to 'tools/profile_chrome')
-rw-r--r-- | tools/profile_chrome/chrome_controller.py | 34 | ||||
-rw-r--r-- | tools/profile_chrome/chrome_startup_controller.py | 23 |
2 files changed, 29 insertions, 28 deletions
diff --git a/tools/profile_chrome/chrome_controller.py b/tools/profile_chrome/chrome_controller.py index 9f52263..d8cff46 100644 --- a/tools/profile_chrome/chrome_controller.py +++ b/tools/profile_chrome/chrome_controller.py @@ -9,7 +9,7 @@ import time from profile_chrome import controllers -from pylib import pexpect +from pylib.device import device_errors from pylib.device import intent @@ -23,6 +23,7 @@ class ChromeTracingController(controllers.BaseController): self._package_info = package_info self._categories = categories self._ring_buffer = ring_buffer + self._logcat_monitor = self._device.GetLogcatMonitor() self._trace_file = None self._trace_interval = None self._trace_memory = trace_memory @@ -31,21 +32,21 @@ class ChromeTracingController(controllers.BaseController): re.compile(r'Logging performance trace to file') self._trace_finish_re = \ re.compile(r'Profiler finished[.] Results are in (.*)[.]') - self._device.old_interface.StartMonitoringLogcat(clear=False) def __repr__(self): return 'chrome trace' @staticmethod def GetCategories(device, package_info): - device.BroadcastIntent(intent.Intent( - action='%s.GPU_PROFILER_LIST_CATEGORIES' % package_info.package)) - try: - json_category_list = device.old_interface.WaitForLogMatch( - re.compile(r'{"traceCategoriesList(.*)'), None, timeout=5).group(0) - except pexpect.TIMEOUT: - raise RuntimeError('Performance trace category list marker not found. ' - 'Is the correct version of the browser running?') + with device.GetLogcatMonitor() as logmon: + device.BroadcastIntent(intent.Intent( + action='%s.GPU_PROFILER_LIST_CATEGORIES' % package_info.package)) + try: + json_category_list = logmon.WaitFor( + re.compile(r'{"traceCategoriesList(.*)'), timeout=5).group(0) + except device_errors.CommandTimeoutError: + raise RuntimeError('Performance trace category list marker not found. ' + 'Is the correct version of the browser running?') record_categories = set() disabled_by_default_categories = set() @@ -61,7 +62,7 @@ class ChromeTracingController(controllers.BaseController): def StartTracing(self, interval): self._trace_interval = interval - self._device.old_interface.SyncLogCat() + self._logcat_monitor.Start() start_extras = {'categories': ','.join(self._categories)} if self._ring_buffer: start_extras['continuous'] = None @@ -70,7 +71,7 @@ class ChromeTracingController(controllers.BaseController): extras=start_extras)) if self._trace_memory: - self._device.old_interface.EnableAdbRoot() + self._device.EnableRoot() self._device.SetProp(_HEAP_PROFILE_MMAP_PROPERTY, 1) # Chrome logs two different messages related to tracing: @@ -81,10 +82,9 @@ class ChromeTracingController(controllers.BaseController): # The first one is printed when tracing starts and the second one indicates # that the trace file is ready to be pulled. try: - self._device.old_interface.WaitForLogMatch( - self._trace_start_re, None, timeout=5) + self._logcat_monitor.WaitFor(self._trace_start_re, timeout=5) self._is_tracing = True - except pexpect.TIMEOUT: + except device_errors.CommandTimeoutError: raise RuntimeError('Trace start marker not found. Is the correct version ' 'of the browser running?') @@ -92,8 +92,8 @@ class ChromeTracingController(controllers.BaseController): if self._is_tracing: self._device.BroadcastIntent(intent.Intent( action='%s.GPU_PROFILER_STOP' % self._package_info.package)) - self._trace_file = self._device.old_interface.WaitForLogMatch( - self._trace_finish_re, None, timeout=120).group(1) + self._trace_file = self._logcat_monitor.WaitFor( + self._trace_finish_re, timeout=120).group(1) self._is_tracing = False if self._trace_memory: self._device.SetProp(_HEAP_PROFILE_MMAP_PROPERTY, 0) diff --git a/tools/profile_chrome/chrome_startup_controller.py b/tools/profile_chrome/chrome_startup_controller.py index 8852cfe..d685502 100644 --- a/tools/profile_chrome/chrome_startup_controller.py +++ b/tools/profile_chrome/chrome_startup_controller.py @@ -16,10 +16,10 @@ class ChromeStartupTracingController(controllers.BaseController): self._device = device self._package_info = package_info self._cold = cold + self._logcat_monitor = self._device.GetLogcatMonitor() self._url = url self._trace_file = None self._trace_finish_re = re.compile(r' Completed startup tracing to (.*)') - self._device.old_interface.StartMonitoringLogcat(clear=False) def __repr__(self): return 'Browser Startup Trace' @@ -30,15 +30,16 @@ class ChromeStartupTracingController(controllers.BaseController): changer = flag_changer.FlagChanger( self._device, self._package_info.cmdline_file) changer.AddFlags(['--trace-startup']) - self._device.old_interface.CloseApplication(self._package_info.package) + self._device.ForceStop(self._package_info.package) if self._cold: - self._device.old_interface.EnableAdbRoot() + self._device.EnableRoot() cache_control.CacheControl(self._device).DropRamCaches() - self._device.old_interface.StartActivity( - package=self._package_info.package, - activity=self._package_info.activity, - data=self._url, - extras={'create_new_tab' : True}) + self._device.StartActivity( + intent.Intent( + package=self._package_info.package, + activity=self._package_info.activity, + data=self._url, + extras={'create_new_tab' : True})) def _TearDownTracing(self): changer = flag_changer.FlagChanger( @@ -47,12 +48,12 @@ class ChromeStartupTracingController(controllers.BaseController): def StartTracing(self, interval): self._SetupTracing() - self._device.old_interface.SyncLogCat() + self._logcat_monitor.Start() def StopTracing(self): try: - self._trace_file = self._device.old_interface.WaitForLogMatch( - self._trace_finish_re, None, timeout=10).group(1) + self._trace_file = self._logcat_monitor.WaitFor( + self._trace_finish_re).group(1) finally: self._TearDownTracing() |