| OLD | NEW |
| 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 |
| 11 from systrace import trace_result | 11 from systrace import trace_result |
| 12 from systrace import tracing_agents | 12 from systrace import tracing_agents |
| 13 from telemetry.timeline import trace_data as trace_data_module |
| 13 | 14 |
| 14 | 15 |
| 15 _DDMS_SAMPLING_FREQUENCY_US = 100 | 16 _DDMS_SAMPLING_FREQUENCY_US = 100 |
| 16 | 17 |
| 17 | 18 |
| 18 class DdmsAgent(tracing_agents.TracingAgent): | 19 class DdmsAgent(tracing_agents.TracingAgent): |
| 19 def __init__(self, device, package_info): | 20 def __init__(self, device, package_info): |
| 20 tracing_agents.TracingAgent.__init__(self) | 21 tracing_agents.TracingAgent.__init__(self) |
| 21 self._device = device | 22 self._device = device |
| 22 self._package = package_info.package | 23 self._package = package_info.package |
| (...skipping 24 matching lines...) Expand all Loading... |
| 47 def StopAgentTracing(self, timeout=None): | 48 def StopAgentTracing(self, timeout=None): |
| 48 self._device.RunShellCommand('am profile stop %s' % self._package) | 49 self._device.RunShellCommand('am profile stop %s' % self._package) |
| 49 return True | 50 return True |
| 50 | 51 |
| 51 @py_utils.Timeout(tracing_agents.GET_RESULTS_TIMEOUT) | 52 @py_utils.Timeout(tracing_agents.GET_RESULTS_TIMEOUT) |
| 52 def GetResults(self, timeout=None): | 53 def GetResults(self, timeout=None): |
| 53 with open(self._PullTrace(), 'r') as f: | 54 with open(self._PullTrace(), 'r') as f: |
| 54 trace_data = f.read() | 55 trace_data = f.read() |
| 55 return trace_result.TraceResult('ddms', trace_data) | 56 return trace_result.TraceResult('ddms', trace_data) |
| 56 | 57 |
| 58 def CollectAgentTraceData(self, trace_data_builder): |
| 59 with open(self._PullTrace(), 'r') as f: |
| 60 trace_data = f.read() |
| 61 trace_data_builder(trace_data_module.DDMS_TRACE_PART, trace_data) |
| 62 |
| 57 def _PullTrace(self): | 63 def _PullTrace(self): |
| 58 if not self._output_file: | 64 if not self._output_file: |
| 59 return None | 65 return None |
| 60 | 66 |
| 61 host_file = os.path.join( | 67 host_file = os.path.join( |
| 62 os.path.curdir, os.path.basename(self._output_file)) | 68 os.path.curdir, os.path.basename(self._output_file)) |
| 63 self._device.PullFile(self._output_file, host_file) | 69 self._device.PullFile(self._output_file, host_file) |
| 64 return host_file | 70 return host_file |
| 65 | 71 |
| 66 def SupportsExplicitClockSync(self): | 72 def SupportsExplicitClockSync(self): |
| (...skipping 19 matching lines...) Expand all Loading... |
| 86 return None | 92 return None |
| 87 | 93 |
| 88 def add_options(parser): | 94 def add_options(parser): |
| 89 options = optparse.OptionGroup(parser, 'Java tracing') | 95 options = optparse.OptionGroup(parser, 'Java tracing') |
| 90 options.add_option('--ddms', help='Trace Java execution using DDMS ' | 96 options.add_option('--ddms', help='Trace Java execution using DDMS ' |
| 91 'sampling.', action='store_true') | 97 'sampling.', action='store_true') |
| 92 return options | 98 return options |
| 93 | 99 |
| 94 def get_config(options): | 100 def get_config(options): |
| 95 return DdmsConfig(options.device, options.package_info, options.ddms) | 101 return DdmsConfig(options.device, options.package_info, options.ddms) |
| OLD | NEW |