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

Side by Side Diff: systrace/profile_chrome/ddms_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: Rebase 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 profile_chrome import util 10 from profile_chrome import util
10 from systrace import trace_result 11 from systrace import trace_result
11 from systrace import tracing_agents 12 from systrace import tracing_agents
12 13
13 14
14 _DDMS_SAMPLING_FREQUENCY_US = 100 15 _DDMS_SAMPLING_FREQUENCY_US = 100
(...skipping 10 matching lines...) Expand all
25 def __repr__(self): 26 def __repr__(self):
26 return 'ddms profile' 27 return 'ddms profile'
27 28
28 def _SupportsSampling(self): 29 def _SupportsSampling(self):
29 for line in self._device.RunShellCommand('am --help'): 30 for line in self._device.RunShellCommand('am --help'):
30 if re.match(r'.*am profile start.*--sampling', line): 31 if re.match(r'.*am profile start.*--sampling', line):
31 return True 32 return True
32 return False 33 return False
33 34
34 @py_utils.Timeout(tracing_agents.START_STOP_TIMEOUT) 35 @py_utils.Timeout(tracing_agents.START_STOP_TIMEOUT)
35 def StartAgentTracing(self, options, categories, timeout=None): 36 def StartAgentTracing(self, config, timeout=None):
36 self._output_file = ( 37 self._output_file = (
37 '/data/local/tmp/ddms-profile-%s' % util.GetTraceTimestamp()) 38 '/data/local/tmp/ddms-profile-%s' % util.GetTraceTimestamp())
38 cmd = 'am profile start ' 39 cmd = 'am profile start '
39 if self._supports_sampling: 40 if self._supports_sampling:
40 cmd += '--sampling %d ' % _DDMS_SAMPLING_FREQUENCY_US 41 cmd += '--sampling %d ' % _DDMS_SAMPLING_FREQUENCY_US
41 cmd += '%s %s' % (self._package, self._output_file) 42 cmd += '%s %s' % (self._package, self._output_file)
42 self._device.RunShellCommand(cmd) 43 self._device.RunShellCommand(cmd)
43 44
44 @py_utils.Timeout(tracing_agents.START_STOP_TIMEOUT) 45 @py_utils.Timeout(tracing_agents.START_STOP_TIMEOUT)
45 def StopAgentTracing(self, timeout=None): 46 def StopAgentTracing(self, timeout=None):
(...skipping 13 matching lines...) Expand all
59 os.path.curdir, os.path.basename(self._output_file)) 60 os.path.curdir, os.path.basename(self._output_file))
60 self._device.PullFile(self._output_file, host_file) 61 self._device.PullFile(self._output_file, host_file)
61 return host_file 62 return host_file
62 63
63 def SupportsExplicitClockSync(self): 64 def SupportsExplicitClockSync(self):
64 return False 65 return False
65 66
66 def RecordClockSyncMarker(self, sync_id, did_record_sync_marker_callback): 67 def RecordClockSyncMarker(self, sync_id, did_record_sync_marker_callback):
67 assert self.SupportsExplicitClockSync(), ('Clock sync marker cannot be ' 68 assert self.SupportsExplicitClockSync(), ('Clock sync marker cannot be '
68 'recorded since explicit clock sync is not supported.') 69 'recorded since explicit clock sync is not supported.')
70
71
72 class DdmsConfig(tracing_agents.TracingConfig):
73 def __init__(self):
74 tracing_agents.TracingConfig.__init__(self)
75
76
77 def add_options(parser):
78 options = optparse.OptionGroup(parser, 'Java tracing')
79 options.add_option('--ddms', help='Trace Java execution using DDMS '
80 'sampling.', action='store_true')
81 return options
82
83 def get_config(options):
84 # pylint: disable=unused-argument
85 return DdmsConfig()
OLDNEW
« no previous file with comments | « systrace/profile_chrome/chrome_tracing_agent_unittest.py ('k') | systrace/profile_chrome/ddms_tracing_agent_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698