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 subprocess | 7 import subprocess |
| 8 import sys | 8 import sys |
| 9 import tempfile | 9 import tempfile |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 self._log_file = tempfile.TemporaryFile() | 51 self._log_file = tempfile.TemporaryFile() |
| 52 | 52 |
| 53 device_param = (['-s', self._device.old_interface.GetDevice()] | 53 device_param = (['-s', self._device.old_interface.GetDevice()] |
| 54 if self._device.old_interface.GetDevice() else []) | 54 if self._device.old_interface.GetDevice() else []) |
| 55 cmd = ['adb'] + device_param + \ | 55 cmd = ['adb'] + device_param + \ |
| 56 ['shell', perf_binary, 'record', | 56 ['shell', perf_binary, 'record', |
| 57 '--output', self._output_file.name] + _PERF_OPTIONS | 57 '--output', self._output_file.name] + _PERF_OPTIONS |
| 58 if categories: | 58 if categories: |
| 59 cmd += ['--event', ','.join(categories)] | 59 cmd += ['--event', ','.join(categories)] |
| 60 self._perf_control = perf_control.PerfControl(self._device) | 60 self._perf_control = perf_control.PerfControl(self._device) |
| 61 self._perf_control.ForceAllCpusOnline(True) | 61 self._perf_control.ForceHighPerfMode(True) |
|
Sami
2014/06/19 18:12:43
True should be removed, right?
BTW, tools/android
epenner
2014/06/19 23:58:50
Thanks. I ran the above and the other test manuall
| |
| 62 self._perf_process = subprocess.Popen(cmd, | 62 self._perf_process = subprocess.Popen(cmd, |
| 63 stdout=self._log_file, | 63 stdout=self._log_file, |
| 64 stderr=subprocess.STDOUT) | 64 stderr=subprocess.STDOUT) |
| 65 | 65 |
| 66 def SignalAndWait(self): | 66 def SignalAndWait(self): |
| 67 perf_pids = self._device.old_interface.ExtractPid('perf') | 67 perf_pids = self._device.old_interface.ExtractPid('perf') |
| 68 self._device.RunShellCommand('kill -SIGINT ' + ' '.join(perf_pids)) | 68 self._device.RunShellCommand('kill -SIGINT ' + ' '.join(perf_pids)) |
| 69 self._perf_process.wait() | 69 self._perf_process.wait() |
| 70 self._perf_control.ForceAllCpusOnline(False) | 70 self._perf_control.SetDefaultPerfMode() |
| 71 | 71 |
| 72 def _FailWithLog(self, msg): | 72 def _FailWithLog(self, msg): |
| 73 self._log_file.seek(0) | 73 self._log_file.seek(0) |
| 74 log = self._log_file.read() | 74 log = self._log_file.read() |
| 75 raise RuntimeError('%s. Log output:\n%s' % (msg, log)) | 75 raise RuntimeError('%s. Log output:\n%s' % (msg, log)) |
| 76 | 76 |
| 77 def PullResult(self, output_path): | 77 def PullResult(self, output_path): |
| 78 if not self._device.old_interface.FileExistsOnDevice( | 78 if not self._device.old_interface.FileExistsOnDevice( |
| 79 self._output_file.name): | 79 self._output_file.name): |
| 80 self._FailWithLog('Perf recorded no data') | 80 self._FailWithLog('Perf recorded no data') |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 181 open(json_file_name, 'w') as json_file: | 181 open(json_file_name, 'w') as json_file: |
| 182 cmd = [perfhost_path, 'script', '-s', perf_script_path, '-i', | 182 cmd = [perfhost_path, 'script', '-s', perf_script_path, '-i', |
| 183 perf_profile, '--symfs', symfs_dir, '--kallsyms', kallsyms] | 183 perf_profile, '--symfs', symfs_dir, '--kallsyms', kallsyms] |
| 184 if subprocess.call(cmd, stdout=json_file, stderr=dev_null): | 184 if subprocess.call(cmd, stdout=json_file, stderr=dev_null): |
| 185 logging.warning('Perf data to JSON conversion failed. The result will ' | 185 logging.warning('Perf data to JSON conversion failed. The result will ' |
| 186 'not contain any perf samples. You can still view the ' | 186 'not contain any perf samples. You can still view the ' |
| 187 'perf data manually as shown above.') | 187 'perf data manually as shown above.') |
| 188 return None | 188 return None |
| 189 | 189 |
| 190 return json_file_name | 190 return json_file_name |
| OLD | NEW |