Chromium Code Reviews| 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 os | 6 import os |
| 7 import signal | 7 import signal |
| 8 import subprocess | 8 import subprocess |
| 9 import sys | 9 import sys |
| 10 import tempfile | 10 import tempfile |
| 11 | 11 |
| 12 from profile_chrome import controllers | 12 from profile_chrome import controllers |
| 13 from profile_chrome import ui | 13 from profile_chrome import ui |
| 14 | 14 |
| 15 from pylib import android_commands | |
| 16 from pylib import constants | 15 from pylib import constants |
| 17 from pylib.perf import perf_control | 16 from pylib.perf import perf_control |
| 17 from pylib.utils import device_temp_file | |
| 18 | 18 |
| 19 sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT, | 19 sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT, |
| 20 'tools', | 20 'tools', |
| 21 'telemetry')) | 21 'telemetry')) |
| 22 try: | 22 try: |
| 23 # pylint: disable=F0401 | 23 # pylint: disable=F0401 |
| 24 from telemetry.core.platform.profiler import android_profiling_helper | 24 from telemetry.core.platform.profiler import android_profiling_helper |
| 25 from telemetry.util import support_binaries | 25 from telemetry.util import support_binaries |
| 26 except ImportError: | 26 except ImportError: |
| 27 android_profiling_helper = None | 27 android_profiling_helper = None |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 40 # Record raw samples to get CPU information. | 40 # Record raw samples to get CPU information. |
| 41 '--raw-samples', | 41 '--raw-samples', |
| 42 # Increase sampling frequency for better coverage. | 42 # Increase sampling frequency for better coverage. |
| 43 '--freq', '2000', | 43 '--freq', '2000', |
| 44 ] | 44 ] |
| 45 | 45 |
| 46 | 46 |
| 47 class _PerfProfiler(object): | 47 class _PerfProfiler(object): |
| 48 def __init__(self, device, perf_binary, categories): | 48 def __init__(self, device, perf_binary, categories): |
| 49 self._device = device | 49 self._device = device |
| 50 self._output_file = android_commands.DeviceTempFile( | 50 self._output_file = device_temp_file.DeviceTempFile( |
| 51 self._device.old_interface, prefix='perf_output') | 51 self._device.adb, prefix='perf_output') |
| 52 self._log_file = tempfile.TemporaryFile() | 52 self._log_file = tempfile.TemporaryFile() |
| 53 | 53 self._device.RunShellCommand( |
|
Sami
2015/05/12 18:37:10
This command should still be run asynchronously by
jbudorick
2015/05/13 03:21:22
Ah, that's the part I missed. Reverted.
Also, thi
Sami
2015/05/13 12:58:50
Yeah this is pretty bad. Maybe there's a cleaner A
jbudorick
2015/05/13 21:49:28
Perhaps. Both telemetry and the video recorder bot
| |
| 54 # TODO(jbudorick) Look at providing a way to unhandroll this once the | 54 [perf_binary, 'record', '--output', self._output_file.name] + |
| 55 # adb rewrite has fully landed. | 55 _PERF_OPTIONS, |
| 56 device_param = (['-s', str(self._device)] if str(self._device) else []) | 56 check_return=True) |
| 57 cmd = ['adb'] + device_param + \ | |
| 58 ['shell', perf_binary, 'record', | |
| 59 '--output', self._output_file.name] + _PERF_OPTIONS | |
| 60 if categories: | 57 if categories: |
| 61 cmd += ['--event', ','.join(categories)] | 58 cmd += ['--event', ','.join(categories)] |
| 62 self._perf_control = perf_control.PerfControl(self._device) | 59 self._perf_control = perf_control.PerfControl(self._device) |
| 63 self._perf_control.SetPerfProfilingMode() | 60 self._perf_control.SetPerfProfilingMode() |
| 64 self._perf_process = subprocess.Popen(cmd, | 61 self._perf_process = subprocess.Popen(cmd, |
| 65 stdout=self._log_file, | 62 stdout=self._log_file, |
| 66 stderr=subprocess.STDOUT) | 63 stderr=subprocess.STDOUT) |
| 67 | 64 |
| 68 def SignalAndWait(self): | 65 def SignalAndWait(self): |
| 69 self._device.KillAll('perf', signum=signal.SIGINT) | 66 self._device.KillAll('perf', signum=signal.SIGINT) |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 open(json_file_name, 'w') as json_file: | 176 open(json_file_name, 'w') as json_file: |
| 180 cmd = [perfhost_path, 'script', '-s', perf_script_path, '-i', | 177 cmd = [perfhost_path, 'script', '-s', perf_script_path, '-i', |
| 181 perf_profile, '--symfs', symfs_dir, '--kallsyms', kallsyms] | 178 perf_profile, '--symfs', symfs_dir, '--kallsyms', kallsyms] |
| 182 if subprocess.call(cmd, stdout=json_file, stderr=dev_null): | 179 if subprocess.call(cmd, stdout=json_file, stderr=dev_null): |
| 183 logging.warning('Perf data to JSON conversion failed. The result will ' | 180 logging.warning('Perf data to JSON conversion failed. The result will ' |
| 184 'not contain any perf samples. You can still view the ' | 181 'not contain any perf samples. You can still view the ' |
| 185 'perf data manually as shown above.') | 182 'perf data manually as shown above.') |
| 186 return None | 183 return None |
| 187 | 184 |
| 188 return json_file_name | 185 return json_file_name |
| OLD | NEW |