| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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.SetDefaultPerfMode() | 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.FileExists(self._output_file.name): |
| 79 self._output_file.name): | |
| 80 self._FailWithLog('Perf recorded no data') | 79 self._FailWithLog('Perf recorded no data') |
| 81 | 80 |
| 82 perf_profile = os.path.join(output_path, | 81 perf_profile = os.path.join(output_path, |
| 83 os.path.basename(self._output_file.name)) | 82 os.path.basename(self._output_file.name)) |
| 84 self._device.old_interface.PullFileFromDevice(self._output_file.name, | 83 self._device.PullFile(self._output_file.name, perf_profile) |
| 85 perf_profile) | |
| 86 if not os.stat(perf_profile).st_size: | 84 if not os.stat(perf_profile).st_size: |
| 87 os.remove(perf_profile) | 85 os.remove(perf_profile) |
| 88 self._FailWithLog('Perf recorded a zero-sized file') | 86 self._FailWithLog('Perf recorded a zero-sized file') |
| 89 | 87 |
| 90 self._log_file.close() | 88 self._log_file.close() |
| 91 self._output_file.close() | 89 self._output_file.close() |
| 92 return perf_profile | 90 return perf_profile |
| 93 | 91 |
| 94 | 92 |
| 95 class PerfProfilerController(controllers.BaseController): | 93 class PerfProfilerController(controllers.BaseController): |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 open(json_file_name, 'w') as json_file: | 179 open(json_file_name, 'w') as json_file: |
| 182 cmd = [perfhost_path, 'script', '-s', perf_script_path, '-i', | 180 cmd = [perfhost_path, 'script', '-s', perf_script_path, '-i', |
| 183 perf_profile, '--symfs', symfs_dir, '--kallsyms', kallsyms] | 181 perf_profile, '--symfs', symfs_dir, '--kallsyms', kallsyms] |
| 184 if subprocess.call(cmd, stdout=json_file, stderr=dev_null): | 182 if subprocess.call(cmd, stdout=json_file, stderr=dev_null): |
| 185 logging.warning('Perf data to JSON conversion failed. The result will ' | 183 logging.warning('Perf data to JSON conversion failed. The result will ' |
| 186 'not contain any perf samples. You can still view the ' | 184 'not contain any perf samples. You can still view the ' |
| 187 'perf data manually as shown above.') | 185 'perf data manually as shown above.') |
| 188 return None | 186 return None |
| 189 | 187 |
| 190 return json_file_name | 188 return json_file_name |
| OLD | NEW |