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

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

Issue 2276263003: Pass in custom options to Systrace agents (Closed) Base URL: https://chromium.googlesource.com/external/github.com/catapult-project/catapult.git@master
Patch Set: Resolve style errors and ensure ftrace gets command-line categories as well 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 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 optparse
5 import os 6 import os
6 import py_utils 7 import py_utils
7 import re 8 import re
8 9
9 from devil.android import flag_changer 10 from devil.android import flag_changer
10 from devil.android.perf import cache_control 11 from devil.android.perf import cache_control
11 from devil.android.sdk import intent 12 from devil.android.sdk import intent
12 13
13 from systrace import trace_result 14 from systrace import trace_result
14 from systrace import tracing_agents 15 from systrace import tracing_agents
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 package=self._package_info.package, 50 package=self._package_info.package,
50 activity=self._package_info.activity, 51 activity=self._package_info.activity,
51 data=self._url, 52 data=self._url,
52 extras={'create_new_tab': True}) 53 extras={'create_new_tab': True})
53 self._device.StartActivity(launch_intent, blocking=True) 54 self._device.StartActivity(launch_intent, blocking=True)
54 55
55 def _TearDownTracing(self): 56 def _TearDownTracing(self):
56 self._flag_changer.Restore() 57 self._flag_changer.Restore()
57 58
58 @py_utils.Timeout(tracing_agents.START_STOP_TIMEOUT) 59 @py_utils.Timeout(tracing_agents.START_STOP_TIMEOUT)
59 def StartAgentTracing(self, options, categories, timeout=None): 60 def StartAgentTracing(self, config, timeout=None):
60 self._SetupTracing() 61 self._SetupTracing()
61 self._logcat_monitor.Start() 62 self._logcat_monitor.Start()
62 63
63 @py_utils.Timeout(tracing_agents.START_STOP_TIMEOUT) 64 @py_utils.Timeout(tracing_agents.START_STOP_TIMEOUT)
64 def StopAgentTracing(self, timeout=None): 65 def StopAgentTracing(self, timeout=None):
65 try: 66 try:
66 self._trace_file = self._logcat_monitor.WaitFor( 67 self._trace_file = self._logcat_monitor.WaitFor(
67 self._trace_finish_re).group(1) 68 self._trace_finish_re).group(1)
68 finally: 69 finally:
69 self._TearDownTracing() 70 self._TearDownTracing()
70 71
71 @py_utils.Timeout(tracing_agents.GET_RESULTS_TIMEOUT) 72 @py_utils.Timeout(tracing_agents.GET_RESULTS_TIMEOUT)
72 def GetResults(self, timeout=None): 73 def GetResults(self, timeout=None):
73 with open(self._PullTrace(), 'r') as f: 74 with open(self._PullTrace(), 'r') as f:
74 trace_data = f.read() 75 trace_data = f.read()
75 return trace_result.TraceResult('traceEvents', trace_data) 76 return trace_result.TraceResult('traceEvents', trace_data)
76 77
77 def _PullTrace(self): 78 def _PullTrace(self):
78 trace_file = self._trace_file.replace('/storage/emulated/0/', '/sdcard/') 79 trace_file = self._trace_file.replace('/storage/emulated/0/', '/sdcard/')
79 host_file = os.path.join(os.path.curdir, os.path.basename(trace_file)) 80 host_file = os.path.join(os.path.curdir, os.path.basename(trace_file))
80 self._device.PullFile(trace_file, host_file) 81 self._device.PullFile(trace_file, host_file)
81 return host_file 82 return host_file
82 83
83 def SupportsExplicitClockSync(self): 84 def SupportsExplicitClockSync(self):
84 return False 85 return False
85 86
86 def RecordClockSyncMarker(self, sync_id, did_record_sync_marker_callback): 87 def RecordClockSyncMarker(self, sync_id, did_record_sync_marker_callback):
87 assert self.SupportsExplicitClockSync(), ('Clock sync marker cannot be ' 88 assert self.SupportsExplicitClockSync(), ('Clock sync marker cannot be '
88 'recorded since explicit clock sync is not supported.') 89 'recorded since explicit clock sync is not supported.')
90
91
92 class ChromeStartupConfig(tracing_agents.TracingConfig):
93 def __init__(self):
94 tracing_agents.TracingConfig.__init__(self)
95
96
97 def add_options(parser):
98 # The Chrome startup agent is not exposed to the user and thus has no
99 # command line options.
Zhen Wang 2016/08/27 15:32:41 The comments need some revision. startup tracing's
washingtonp 2016/08/29 06:40:02 Done.
100 options = optparse.OptionGroup(parser, '')
101 return options
102
103 def get_config(options):
104 # pylint: disable=unused-argument
105 return ChromeStartupConfig()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698