| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 re | 7 import re |
| 8 import signal | 8 import signal |
| 9 import subprocess | 9 import subprocess |
| 10 import sys | 10 import sys |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 if self._is_android: | 85 if self._is_android: |
| 86 cmd_prefix = [ | 86 cmd_prefix = [ |
| 87 browser_backend.device.adb.GetAdbPath(), | 87 browser_backend.device.adb.GetAdbPath(), |
| 88 '-s', browser_backend.device.adb.GetDeviceSerial(), | 88 '-s', browser_backend.device.adb.GetDeviceSerial(), |
| 89 'shell', perf_binary] | 89 'shell', perf_binary] |
| 90 perf_args += _PERF_OPTIONS_ANDROID | 90 perf_args += _PERF_OPTIONS_ANDROID |
| 91 output_file = os.path.join('/sdcard', 'perf_profiles', | 91 output_file = os.path.join('/sdcard', 'perf_profiles', |
| 92 os.path.basename(output_file)) | 92 os.path.basename(output_file)) |
| 93 self._device_output_file = output_file | 93 self._device_output_file = output_file |
| 94 browser_backend.device.RunShellCommand( | 94 browser_backend.device.RunShellCommand( |
| 95 'mkdir -p ' + os.path.dirname(self._device_output_file)) | 95 ['mkdir', '-p', os.path.dirname(self._device_output_file)], |
| 96 browser_backend.device.RunShellCommand( | 96 check_return=True) |
| 97 'rm -f ' + self._device_output_file) | 97 browser_backend.device.RemovePath(self._device_output_file, force=True) |
| 98 else: | 98 else: |
| 99 cmd_prefix = [perf_binary] | 99 cmd_prefix = [perf_binary] |
| 100 perf_args += ['--output', output_file] + _PERF_OPTIONS | 100 perf_args += ['--output', output_file] + _PERF_OPTIONS |
| 101 self._proc = subprocess.Popen(cmd_prefix + perf_args, | 101 self._proc = subprocess.Popen(cmd_prefix + perf_args, |
| 102 stdout=self._tmp_output_file, stderr=subprocess.STDOUT) | 102 stdout=self._tmp_output_file, stderr=subprocess.STDOUT) |
| 103 | 103 |
| 104 def CollectProfile(self): | 104 def CollectProfile(self): |
| 105 if ('renderer' in self._output_file and | 105 if ('renderer' in self._output_file and |
| 106 not self._is_android and | 106 not self._is_android and |
| 107 not self._platform_backend.GetCommandLine(self._pid)): | 107 not self._platform_backend.GetCommandLine(self._pid)): |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 if len(fields) != 5: | 248 if len(fields) != 5: |
| 249 continue | 249 continue |
| 250 period = int(fields[1]) | 250 period = int(fields[1]) |
| 251 function = fields[4].partition(' ')[2] | 251 function = fields[4].partition(' ')[2] |
| 252 function = re.sub('<.*>', '', function) # Strip template params. | 252 function = re.sub('<.*>', '', function) # Strip template params. |
| 253 function = re.sub('[(].*[)]', '', function) # Strip function params. | 253 function = re.sub('[(].*[)]', '', function) # Strip function params. |
| 254 period_by_function[function] = period | 254 period_by_function[function] = period |
| 255 if len(period_by_function) == number: | 255 if len(period_by_function) == number: |
| 256 break | 256 break |
| 257 return period_by_function | 257 return period_by_function |
| OLD | NEW |