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

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

Issue 2297403003: Use Systrace tracing controller in profile_chrome (Closed) Base URL: https://chromium.googlesource.com/external/github.com/catapult-project/catapult.git@master
Patch Set: Added property method for tracing controller's child agents 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 optparse
6 import os 6 import os
7 import py_utils 7 import py_utils
8 import re 8 import re
9 9
10 from profile_chrome import util 10 from profile_chrome import util
(...skipping 23 matching lines...) Expand all
34 34
35 @py_utils.Timeout(tracing_agents.START_STOP_TIMEOUT) 35 @py_utils.Timeout(tracing_agents.START_STOP_TIMEOUT)
36 def StartAgentTracing(self, config, timeout=None): 36 def StartAgentTracing(self, config, timeout=None):
37 self._output_file = ( 37 self._output_file = (
38 '/data/local/tmp/ddms-profile-%s' % util.GetTraceTimestamp()) 38 '/data/local/tmp/ddms-profile-%s' % util.GetTraceTimestamp())
39 cmd = 'am profile start ' 39 cmd = 'am profile start '
40 if self._supports_sampling: 40 if self._supports_sampling:
41 cmd += '--sampling %d ' % _DDMS_SAMPLING_FREQUENCY_US 41 cmd += '--sampling %d ' % _DDMS_SAMPLING_FREQUENCY_US
42 cmd += '%s %s' % (self._package, self._output_file) 42 cmd += '%s %s' % (self._package, self._output_file)
43 self._device.RunShellCommand(cmd) 43 self._device.RunShellCommand(cmd)
44 return True
44 45
45 @py_utils.Timeout(tracing_agents.START_STOP_TIMEOUT) 46 @py_utils.Timeout(tracing_agents.START_STOP_TIMEOUT)
46 def StopAgentTracing(self, timeout=None): 47 def StopAgentTracing(self, timeout=None):
47 self._device.RunShellCommand('am profile stop %s' % self._package) 48 self._device.RunShellCommand('am profile stop %s' % self._package)
49 return True
48 50
49 @py_utils.Timeout(tracing_agents.GET_RESULTS_TIMEOUT) 51 @py_utils.Timeout(tracing_agents.GET_RESULTS_TIMEOUT)
50 def GetResults(self, timeout=None): 52 def GetResults(self, timeout=None):
51 with open(self._PullTrace(), 'r') as f: 53 with open(self._PullTrace(), 'r') as f:
52 trace_data = f.read() 54 trace_data = f.read()
53 return trace_result.TraceResult('ddms', trace_data) 55 return trace_result.TraceResult('ddms', trace_data)
54 56
55 def _PullTrace(self): 57 def _PullTrace(self):
56 if not self._output_file: 58 if not self._output_file:
57 return None 59 return None
58 60
59 host_file = os.path.join( 61 host_file = os.path.join(
60 os.path.curdir, os.path.basename(self._output_file)) 62 os.path.curdir, os.path.basename(self._output_file))
61 self._device.PullFile(self._output_file, host_file) 63 self._device.PullFile(self._output_file, host_file)
62 return host_file 64 return host_file
63 65
64 def SupportsExplicitClockSync(self): 66 def SupportsExplicitClockSync(self):
65 return False 67 return False
66 68
67 def RecordClockSyncMarker(self, sync_id, did_record_sync_marker_callback): 69 def RecordClockSyncMarker(self, sync_id, did_record_sync_marker_callback):
70 # pylint: disable=unused-argument
68 assert self.SupportsExplicitClockSync(), ('Clock sync marker cannot be ' 71 assert self.SupportsExplicitClockSync(), ('Clock sync marker cannot be '
69 'recorded since explicit clock sync is not supported.') 72 'recorded since explicit clock sync is not supported.')
70 73
71 74
72 class DdmsConfig(tracing_agents.TracingConfig): 75 class DdmsConfig(tracing_agents.TracingConfig):
73 def __init__(self): 76 def __init__(self, device, package_info, ddms):
74 tracing_agents.TracingConfig.__init__(self) 77 tracing_agents.TracingConfig.__init__(self)
78 self.device = device
79 self.package_info = package_info
80 self.ddms = ddms
75 81
76 82
83 def try_create_agent(config):
84 if config.ddms:
85 return DdmsAgent(config.device, config.package_info)
86 return None
87
77 def add_options(parser): 88 def add_options(parser):
78 options = optparse.OptionGroup(parser, 'Java tracing') 89 options = optparse.OptionGroup(parser, 'Java tracing')
79 options.add_option('--ddms', help='Trace Java execution using DDMS ' 90 options.add_option('--ddms', help='Trace Java execution using DDMS '
80 'sampling.', action='store_true') 91 'sampling.', action='store_true')
81 return options 92 return options
82 93
83 def get_config(options): 94 def get_config(options):
84 # pylint: disable=unused-argument 95 return DdmsConfig(options.device, options.package_info, options.ddms)
85 return DdmsConfig()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698