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

Side by Side Diff: systrace/profile_chrome/chrome_tracing_agent.py

Issue 2295913002: Enable some profile_chrome unit tests on Trybots (Closed) Base URL: https://chromium.googlesource.com/external/github.com/catapult-project/catapult.git@master
Patch Set: Disable DDMS test because it is flaky Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import json 5 import json
6 import optparse 6 import optparse
7 import os 7 import os
8 import py_utils 8 import py_utils
9 import re 9 import re
10 from profile_chrome import util
10 11
11 from devil.android import device_errors 12 from devil.android import device_errors
12 from devil.android.sdk import intent 13 from devil.android.sdk import intent
13
14 from systrace import trace_result 14 from systrace import trace_result
15 from systrace import tracing_agents 15 from systrace import tracing_agents
16 16
17 17
18 _DEFAULT_CHROME_CATEGORIES = '_DEFAULT_CHROME_CATEGORIES' 18 _DEFAULT_CHROME_CATEGORIES = '_DEFAULT_CHROME_CATEGORIES'
19 _HEAP_PROFILE_MMAP_PROPERTY = 'heapprof.mmap' 19 _HEAP_PROFILE_MMAP_PROPERTY = 'heapprof.mmap'
20 20
21 21
22 class ChromeTracingAgent(tracing_agents.TracingAgent): 22 class ChromeTracingAgent(tracing_agents.TracingAgent):
23 def __init__(self, device, package_info, ring_buffer, trace_memory=False): 23 def __init__(self, device, package_info, ring_buffer, trace_memory=False):
24 tracing_agents.TracingAgent.__init__(self) 24 tracing_agents.TracingAgent.__init__(self)
25 self._device = device 25 self._device = device
26 self._package_info = package_info 26 self._package_info = package_info
27 self._ring_buffer = ring_buffer 27 self._ring_buffer = ring_buffer
28 self._logcat_monitor = self._device.GetLogcatMonitor() 28 self._logcat_monitor = self._device.GetLogcatMonitor()
29 self._trace_file = None 29 self._trace_file = None
30 self._trace_memory = trace_memory 30 self._trace_memory = trace_memory
31 self._is_tracing = False 31 self._is_tracing = False
32 self._trace_start_re = \ 32 self._trace_start_re = \
33 re.compile(r'Logging performance trace to file') 33 re.compile(r'Logging performance trace to file')
34 self._trace_finish_re = \ 34 self._trace_finish_re = \
35 re.compile(r'Profiler finished[.] Results are in (.*)[.]') 35 re.compile(r'Profiler finished[.] Results are in (.*)[.]')
36 self._categories = None 36 self._categories = None
37 37
38 def __repr__(self): 38 def __repr__(self):
39 return 'chrome trace' 39 return 'chrome trace'
40 40
41 @staticmethod 41 @staticmethod
42 def GetCategories(device, package_info): 42 def GetCategories(device, package_info):
43 curr_browser = util.GetChromeProcessID(device, package_info)
Sami 2016/09/09 10:28:25 I don't think the agents should be trying to start
washingtonp 2016/09/09 18:07:29 Done.
44 if curr_browser == None:
45 util.StartBrowser(device, package_info)
43 with device.GetLogcatMonitor() as logmon: 46 with device.GetLogcatMonitor() as logmon:
44 device.BroadcastIntent(intent.Intent( 47 device.BroadcastIntent(intent.Intent(
45 action='%s.GPU_PROFILER_LIST_CATEGORIES' % package_info.package)) 48 action='%s.GPU_PROFILER_LIST_CATEGORIES' % package_info.package))
46 try: 49 try:
47 json_category_list = logmon.WaitFor( 50 json_category_list = logmon.WaitFor(
48 re.compile(r'{"traceCategoriesList(.*)'), timeout=5).group(0) 51 re.compile(r'{"traceCategoriesList(.*)'), timeout=5).group(0)
49 except device_errors.CommandTimeoutError: 52 except device_errors.CommandTimeoutError:
50 raise RuntimeError('Performance trace category list marker not found. ' 53 raise RuntimeError('Performance trace category list marker not found. '
51 'Is the correct version of the browser running?') 54 'Is the correct version of the browser running?')
52 55
53 record_categories = set() 56 record_categories = set()
54 disabled_by_default_categories = set() 57 disabled_by_default_categories = set()
55 json_data = json.loads(json_category_list)['traceCategoriesList'] 58 json_data = json.loads(json_category_list)['traceCategoriesList']
56 for item in json_data: 59 for item in json_data:
57 for category in item.split(','): 60 for category in item.split(','):
58 if category.startswith('disabled-by-default'): 61 if category.startswith('disabled-by-default'):
59 disabled_by_default_categories.add(category) 62 disabled_by_default_categories.add(category)
60 else: 63 else:
61 record_categories.add(category) 64 record_categories.add(category)
62 65
63 return list(record_categories), list(disabled_by_default_categories) 66 return list(record_categories), list(disabled_by_default_categories)
64 67
65 @py_utils.Timeout(tracing_agents.START_STOP_TIMEOUT) 68 @py_utils.Timeout(tracing_agents.START_STOP_TIMEOUT)
66 def StartAgentTracing(self, config, timeout=None): 69 def StartAgentTracing(self, config, timeout=None):
70 curr_browser = util.GetChromeProcessID(self._device, self._package_info)
71 if curr_browser == None:
72 util.StartBrowser(self._device, self._package_info)
67 self._categories = _ComputeChromeCategories(config) 73 self._categories = _ComputeChromeCategories(config)
68 self._logcat_monitor.Start() 74 self._logcat_monitor.Start()
69 start_extras = {'categories': ','.join(self._categories)} 75 start_extras = {'categories': ','.join(self._categories)}
70 if self._ring_buffer: 76 if self._ring_buffer:
71 start_extras['continuous'] = None 77 start_extras['continuous'] = None
72 self._device.BroadcastIntent(intent.Intent( 78 self._device.BroadcastIntent(intent.Intent(
73 action='%s.GPU_PROFILER_START' % self._package_info.package, 79 action='%s.GPU_PROFILER_START' % self._package_info.package,
74 extras=start_extras)) 80 extras=start_extras))
75 81
76 if self._trace_memory: 82 if self._trace_memory:
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 categories.append('disabled-by-default-toplevel.flow') 199 categories.append('disabled-by-default-toplevel.flow')
194 if config.trace_memory: 200 if config.trace_memory:
195 categories.append('disabled-by-default-memory') 201 categories.append('disabled-by-default-memory')
196 if config.trace_scheduler: 202 if config.trace_scheduler:
197 categories.append('disabled-by-default-blink.scheduler') 203 categories.append('disabled-by-default-blink.scheduler')
198 categories.append('disabled-by-default-cc.debug.scheduler') 204 categories.append('disabled-by-default-cc.debug.scheduler')
199 categories.append('disabled-by-default-renderer.scheduler') 205 categories.append('disabled-by-default-renderer.scheduler')
200 if config.chrome_categories: 206 if config.chrome_categories:
201 categories += config.chrome_categories.split(',') 207 categories += config.chrome_categories.split(',')
202 return categories 208 return categories
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698