Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(979)

Side by Side Diff: tools/android/adb_profile_chrome/perf_controller.py

Issue 333933003: [Android] Switch to DeviceUtils version of RunShellCommand. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/tombstones.py ('k') | tools/android/adb_profile_chrome/systrace_controller.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.ForceAllCpusOnline(True)
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.old_interface.RunShellCommand( 68 self._device.RunShellCommand('kill -SIGINT ' + ' '.join(perf_pids))
69 'kill -SIGINT ' + ' '.join(perf_pids))
70 self._perf_process.wait() 69 self._perf_process.wait()
71 self._perf_control.ForceAllCpusOnline(False) 70 self._perf_control.ForceAllCpusOnline(False)
72 71
73 def _FailWithLog(self, msg): 72 def _FailWithLog(self, msg):
74 self._log_file.seek(0) 73 self._log_file.seek(0)
75 log = self._log_file.read() 74 log = self._log_file.read()
76 raise RuntimeError('%s. Log output:\n%s' % (msg, log)) 75 raise RuntimeError('%s. Log output:\n%s' % (msg, log))
77 76
78 def PullResult(self, output_path): 77 def PullResult(self, output_path):
79 if not self._device.old_interface.FileExistsOnDevice( 78 if not self._device.old_interface.FileExistsOnDevice(
(...skipping 30 matching lines...) Expand all
110 109
111 @staticmethod 110 @staticmethod
112 def _PrepareDevice(device): 111 def _PrepareDevice(device):
113 if not 'BUILDTYPE' in os.environ: 112 if not 'BUILDTYPE' in os.environ:
114 os.environ['BUILDTYPE'] = 'Release' 113 os.environ['BUILDTYPE'] = 'Release'
115 return android_profiling_helper.PrepareDeviceForPerf(device) 114 return android_profiling_helper.PrepareDeviceForPerf(device)
116 115
117 @classmethod 116 @classmethod
118 def GetCategories(cls, device): 117 def GetCategories(cls, device):
119 perf_binary = cls._PrepareDevice(device) 118 perf_binary = cls._PrepareDevice(device)
120 return device.old_interface.RunShellCommand('%s list' % perf_binary) 119 return device.RunShellCommand('%s list' % perf_binary)
121 120
122 def StartTracing(self, _): 121 def StartTracing(self, _):
123 self._perf_instance = _PerfProfiler(self._device, 122 self._perf_instance = _PerfProfiler(self._device,
124 self._perf_binary, 123 self._perf_binary,
125 self._categories) 124 self._categories)
126 125
127 def StopTracing(self): 126 def StopTracing(self):
128 if not self._perf_instance: 127 if not self._perf_instance:
129 return 128 return
130 self._perf_instance.SignalAndWait() 129 self._perf_instance.SignalAndWait()
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 open(json_file_name, 'w') as json_file: 181 open(json_file_name, 'w') as json_file:
183 cmd = [perfhost_path, 'script', '-s', perf_script_path, '-i', 182 cmd = [perfhost_path, 'script', '-s', perf_script_path, '-i',
184 perf_profile, '--symfs', symfs_dir, '--kallsyms', kallsyms] 183 perf_profile, '--symfs', symfs_dir, '--kallsyms', kallsyms]
185 if subprocess.call(cmd, stdout=json_file, stderr=dev_null): 184 if subprocess.call(cmd, stdout=json_file, stderr=dev_null):
186 logging.warning('Perf data to JSON conversion failed. The result will ' 185 logging.warning('Perf data to JSON conversion failed. The result will '
187 'not contain any perf samples. You can still view the ' 186 'not contain any perf samples. You can still view the '
188 'perf data manually as shown above.') 187 'perf data manually as shown above.')
189 return None 188 return None
190 189
191 return json_file_name 190 return json_file_name
OLDNEW
« no previous file with comments | « build/android/tombstones.py ('k') | tools/android/adb_profile_chrome/systrace_controller.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698