OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 logging | 5 import logging |
6 import optparse | 6 import optparse |
7 import os | 7 import os |
8 import py_utils | 8 import py_utils |
9 import signal | 9 import signal |
10 import subprocess | 10 import subprocess |
11 import sys | 11 import sys |
12 import tempfile | 12 import tempfile |
13 | 13 |
14 from devil.android import device_temp_file | 14 from devil.android import device_temp_file |
15 from devil.android.perf import perf_control | 15 from devil.android.perf import perf_control |
16 | 16 |
17 from profile_chrome import ui | 17 from profile_chrome import ui |
18 from systrace import trace_result | 18 from systrace import trace_result |
19 from systrace import tracing_agents | 19 from systrace import tracing_agents |
| 20 from telemetry.timeline import trace_data as trace_data_module |
20 | 21 |
21 _CATAPULT_DIR = os.path.join( | 22 _CATAPULT_DIR = os.path.join( |
22 os.path.dirname(os.path.abspath(__file__)), '..', '..') | 23 os.path.dirname(os.path.abspath(__file__)), '..', '..') |
23 sys.path.append(os.path.join(_CATAPULT_DIR, 'telemetry')) | 24 sys.path.append(os.path.join(_CATAPULT_DIR, 'telemetry')) |
24 try: | 25 try: |
25 # pylint: disable=F0401 | 26 # pylint: disable=F0401 |
26 from telemetry.internal.platform.profiler import android_profiling_helper | 27 from telemetry.internal.platform.profiler import android_profiling_helper |
27 from telemetry.internal.util import binary_manager | 28 from telemetry.internal.util import binary_manager |
28 except ImportError: | 29 except ImportError: |
29 android_profiling_helper = None | 30 android_profiling_helper = None |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 return | 136 return |
136 self._perf_instance.SignalAndWait() | 137 self._perf_instance.SignalAndWait() |
137 return True | 138 return True |
138 | 139 |
139 @py_utils.Timeout(tracing_agents.GET_RESULTS_TIMEOUT) | 140 @py_utils.Timeout(tracing_agents.GET_RESULTS_TIMEOUT) |
140 def GetResults(self, timeout=None): | 141 def GetResults(self, timeout=None): |
141 with open(self._PullTrace(), 'r') as f: | 142 with open(self._PullTrace(), 'r') as f: |
142 trace_data = f.read() | 143 trace_data = f.read() |
143 return trace_result.TraceResult('perf', trace_data) | 144 return trace_result.TraceResult('perf', trace_data) |
144 | 145 |
| 146 def CollectAgentTraceData(self, trace_data_builder): |
| 147 with open(self._PullTrace(), 'r') as f: |
| 148 data = f.read() |
| 149 trace_data_builder.AddTraceFor(trace_data_module.PROFILER_TRACE_PART, data) |
| 150 |
145 @staticmethod | 151 @staticmethod |
146 def _GetInteractivePerfCommand(perfhost_path, perf_profile, symfs_dir, | 152 def _GetInteractivePerfCommand(perfhost_path, perf_profile, symfs_dir, |
147 required_libs, kallsyms): | 153 required_libs, kallsyms): |
148 cmd = '%s report -n -i %s --symfs %s --kallsyms %s' % ( | 154 cmd = '%s report -n -i %s --symfs %s --kallsyms %s' % ( |
149 os.path.relpath(perfhost_path, '.'), perf_profile, symfs_dir, kallsyms) | 155 os.path.relpath(perfhost_path, '.'), perf_profile, symfs_dir, kallsyms) |
150 for lib in required_libs: | 156 for lib in required_libs: |
151 lib = os.path.join(symfs_dir, lib[1:]) | 157 lib = os.path.join(symfs_dir, lib[1:]) |
152 if not os.path.exists(lib): | 158 if not os.path.exists(lib): |
153 continue | 159 continue |
154 objdump_path = android_profiling_helper.GetToolchainBinaryPath( | 160 objdump_path = android_profiling_helper.GetToolchainBinaryPath( |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 | 249 |
244 def get_config(options): | 250 def get_config(options): |
245 return PerfConfig(options.perf_categories, options.device) | 251 return PerfConfig(options.perf_categories, options.device) |
246 | 252 |
247 def _ComputePerfCategories(config): | 253 def _ComputePerfCategories(config): |
248 if not PerfProfilerAgent.IsSupported(): | 254 if not PerfProfilerAgent.IsSupported(): |
249 return [] | 255 return [] |
250 if not config.perf_categories: | 256 if not config.perf_categories: |
251 return [] | 257 return [] |
252 return config.perf_categories.split(',') | 258 return config.perf_categories.split(',') |
OLD | NEW |