Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1481)

Unified Diff: tools/profile_chrome/chrome_controller.py

Issue 879853002: Add a --startup option to generate combined traces for startup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/profile_chrome/main.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/profile_chrome/chrome_controller.py
diff --git a/tools/profile_chrome/chrome_controller.py b/tools/profile_chrome/chrome_controller.py
index 9f522631b1e6e6591c49d595a8985f5657e78180..1176518c83f5e616333e8f305ee3f1adba319fbb 100644
--- a/tools/profile_chrome/chrome_controller.py
+++ b/tools/profile_chrome/chrome_controller.py
@@ -9,6 +9,8 @@ import time
from profile_chrome import controllers
+from pylib import android_commands
+from pylib import flag_changer
from pylib import pexpect
from pylib.device import intent
@@ -17,7 +19,8 @@ _HEAP_PROFILE_MMAP_PROPERTY = 'heapprof.mmap'
class ChromeTracingController(controllers.BaseController):
def __init__(self, device, package_info,
- categories, ring_buffer, trace_memory=False):
+ categories, ring_buffer, trace_memory=False,
+ startup=None):
controllers.BaseController.__init__(self)
self._device = device
self._package_info = package_info
@@ -26,10 +29,15 @@ class ChromeTracingController(controllers.BaseController):
self._trace_file = None
self._trace_interval = None
self._trace_memory = trace_memory
+ self._startup = startup
self._is_tracing = False
self._trace_start_re = \
re.compile(r'Logging performance trace to file')
- self._trace_finish_re = \
+ if self._startup:
+ self._trace_finish_re = re.compile(
+ r' Completed startup tracing to (.*)')
+ else:
+ self._trace_finish_re = \
re.compile(r'Profiler finished[.] Results are in (.*)[.]')
self._device.old_interface.StartMonitoringLogcat(clear=False)
@@ -59,7 +67,24 @@ class ChromeTracingController(controllers.BaseController):
return list(record_categories), list(disabled_by_default_categories)
+ def _SetupStartupTracing(self):
+ changer = flag_changer.FlagChanger(
+ self._device, self._package_info.cmdline_file)
+ changer.AddFlags(['--trace-startup'])
+ self._device.old_interface.CloseApplication(self._package_info.package)
+ if self._startup == 'cold':
+ self._device.old_interface.EnableAdbRoot()
+ adb = android_commands.AndroidCommands()
+ adb.RunShellCommand('echo 1 > /proc/vm/drop_caches')
pasko-google - do not use 2015/01/27 15:20:52 There is cache_control.DropRamCaches, which also d
Benoit L 2015/01/27 16:31:33 Done.
+ self._device.old_interface.StartActivity(
+ package=self._package_info.package,
+ activity=self._package_info.activity,
+ data='http://www.google.com/',
+ extras={'create_new_tab' : True})
+
def StartTracing(self, interval):
+ if self._startup:
+ self._SetupStartupTracing()
self._trace_interval = interval
self._device.old_interface.SyncLogCat()
start_extras = {'categories': ','.join(self._categories)}
@@ -80,13 +105,14 @@ 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._is_tracing = True
- except pexpect.TIMEOUT:
- raise RuntimeError('Trace start marker not found. Is the correct version '
- 'of the browser running?')
+ if not self._startup:
+ try:
+ self._device.old_interface.WaitForLogMatch(
+ self._trace_start_re, None, timeout=5)
+ except pexpect.TIMEOUT:
+ raise RuntimeError('Trace start marker not found. Is the correct '
+ 'version of the browser running?')
+ self._is_tracing = True
def StopTracing(self):
if self._is_tracing:
@@ -101,7 +127,6 @@ class ChromeTracingController(controllers.BaseController):
def PullTrace(self):
# Wait a bit for the browser to finish writing the trace file.
time.sleep(self._trace_interval / 4 + 1)
-
trace_file = self._trace_file.replace('/storage/emulated/0/', '/sdcard/')
host_file = os.path.join(os.path.curdir, os.path.basename(trace_file))
self._device.PullFile(trace_file, host_file)
« no previous file with comments | « no previous file | tools/profile_chrome/main.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698