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

Side by Side Diff: telemetry/telemetry/internal/platform/tracing_agent/atrace_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: Refactors 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 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 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 from systrace.tracing_agents import atrace_agent 5 from systrace.tracing_agents import atrace_agent
6 from telemetry.internal.platform import tracing_agent 6 from telemetry.internal.platform import tracing_agent
7 from telemetry.timeline import trace_data 7 from telemetry.timeline import trace_data
8 8
9 from devil.android.sdk import version_codes 9 from devil.android.sdk import version_codes
10 10
11 11
12 class AtraceOpts(object):
13 '''Object that holds Atrace options.
14
15 In systrace, the atrace options are provided by an object generated
16 by argparse. Since we're not using the command line options here and we
17 want to hard-code the relevant options, we create an object here
18 to do so.
19 '''
20
21 def __init__(self, serial_number, app_name):
22 self.compress_trace_data = True
23 self.trace_time = None
24 self.trace_buf_size = None
25 self.app_name = (','.join(app_name) if isinstance(app_name, list)
26 else app_name)
27 self.kfuncs = None
28 self.fix_threads = True
29 self.fix_tgids = True
30 self.fix_circular = True
31 self.device_serial_number = serial_number
32
33 class AtraceTracingAgent(tracing_agent.TracingAgent): 12 class AtraceTracingAgent(tracing_agent.TracingAgent):
34 def __init__(self, platform_backend): 13 def __init__(self, platform_backend):
35 super(AtraceTracingAgent, self).__init__(platform_backend) 14 super(AtraceTracingAgent, self).__init__(platform_backend)
36 self._device = platform_backend.device 15 self._device = platform_backend.device
37 self._categories = None 16 self._categories = None
38 self._atrace_agent = atrace_agent.AtraceAgent() 17 self._atrace_agent = atrace_agent.AtraceAgent()
39 self._options = None 18 self._config = None
40 19
41 @classmethod 20 @classmethod
42 def IsSupported(cls, platform_backend): 21 def IsSupported(cls, platform_backend):
43 return (platform_backend.GetOSName() == 'android' and 22 return (platform_backend.GetOSName() == 'android' and
44 platform_backend.device > version_codes.JELLY_BEAN_MR1) 23 platform_backend.device > version_codes.JELLY_BEAN_MR1)
45 24
46 def StartAgentTracing(self, config, timeout): 25 def StartAgentTracing(self, config, timeout):
47 if not config.enable_atrace_trace: 26 if not config.enable_atrace_trace:
48 return False 27 return False
49 self._categories = config.atrace_config.categories 28
50 self._options = AtraceOpts(str(self._device), config.atrace_config.app_name) 29 app_name = (','.join(config.atrace_config.app_name) if
51 return self._atrace_agent.StartAgentTracing( 30 isinstance(config.atrace_config.app_name, list) else
52 self._options, self._categories, timeout) 31 config.atrace_config.app_name)
32 self._config = atrace_agent.AtraceConfig(config.atrace_config.categories,
33 None, None, app_name, True, True,
34 True, True, None, None,
35 str(self._device), None,
36 'android')
37 return self._atrace_agent.StartAgentTracing(self._config, timeout)
53 38
54 def StopAgentTracing(self): 39 def StopAgentTracing(self):
55 self._atrace_agent.StopAgentTracing() 40 self._atrace_agent.StopAgentTracing()
56 41
57 def SupportsExplicitClockSync(self): 42 def SupportsExplicitClockSync(self):
58 return self._atrace_agent.SupportsExplicitClockSync() 43 return self._atrace_agent.SupportsExplicitClockSync()
59 44
60 def RecordClockSyncMarker(self, sync_id, 45 def RecordClockSyncMarker(self, sync_id,
61 record_controller_clock_sync_marker_callback): 46 record_controller_clock_sync_marker_callback):
62 return self._atrace_agent.RecordClockSyncMarker(sync_id, 47 return self._atrace_agent.RecordClockSyncMarker(sync_id,
63 lambda t, sid: record_controller_clock_sync_marker_callback(sid, t)) 48 lambda t, sid: record_controller_clock_sync_marker_callback(sid, t))
64 49
65 def CollectAgentTraceData(self, trace_data_builder, timeout=None): 50 def CollectAgentTraceData(self, trace_data_builder, timeout=None):
66 raw_data = self._atrace_agent.GetResults(timeout).raw_data 51 raw_data = self._atrace_agent.GetResults(timeout).raw_data
67 trace_data_builder.SetTraceFor(trace_data.ATRACE_PART, raw_data) 52 trace_data_builder.SetTraceFor(trace_data.ATRACE_PART, raw_data)
OLDNEW
« systrace/systrace/run_systrace.py ('K') | « systrace/systrace/tracing_controller.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698