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

Side by Side Diff: build/android/chrome_profiler/perf_controller.py

Issue 316143002: telemetry: Improve perf profiler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Poll quicker. 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | build/android/pylib/perf/perf_control.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
11 from chrome_profiler import controllers 11 from chrome_profiler import controllers
12 12
13 from pylib import android_commands 13 from pylib import android_commands
14 from pylib import constants 14 from pylib import constants
15 from pylib.perf import perf_control
15 16
16 sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT, 17 sys.path.append(os.path.join(constants.DIR_SOURCE_ROOT,
17 'tools', 18 'tools',
18 'telemetry')) 19 'telemetry'))
19 try: 20 try:
20 # pylint: disable=F0401 21 # pylint: disable=F0401
21 from telemetry.core.platform.profiler import android_profiling_helper 22 from telemetry.core.platform.profiler import android_profiling_helper
22 from telemetry.util import support_binaries 23 from telemetry.util import support_binaries
23 except ImportError: 24 except ImportError:
24 android_profiling_helper = None 25 android_profiling_helper = None
(...skipping 23 matching lines...) Expand all
48 self._device.old_interface, prefix='perf_output') 49 self._device.old_interface, prefix='perf_output')
49 self._log_file = tempfile.TemporaryFile() 50 self._log_file = tempfile.TemporaryFile()
50 51
51 device_param = (['-s', self._device.old_interface.GetDevice()] 52 device_param = (['-s', self._device.old_interface.GetDevice()]
52 if self._device.old_interface.GetDevice() else []) 53 if self._device.old_interface.GetDevice() else [])
53 cmd = ['adb'] + device_param + \ 54 cmd = ['adb'] + device_param + \
54 ['shell', perf_binary, 'record', 55 ['shell', perf_binary, 'record',
55 '--output', self._output_file.name] + _PERF_OPTIONS 56 '--output', self._output_file.name] + _PERF_OPTIONS
56 if categories: 57 if categories:
57 cmd += ['--event', ','.join(categories)] 58 cmd += ['--event', ','.join(categories)]
59 self._perf_control = perf_control.PerfControl(self._device)
60 self._perf_control.ForceAllCpusOnline(True)
58 self._perf_process = subprocess.Popen(cmd, 61 self._perf_process = subprocess.Popen(cmd,
59 stdout=self._log_file, 62 stdout=self._log_file,
60 stderr=subprocess.STDOUT) 63 stderr=subprocess.STDOUT)
61 64
62 def SignalAndWait(self): 65 def SignalAndWait(self):
63 perf_pids = self._device.old_interface.ExtractPid('perf') 66 perf_pids = self._device.old_interface.ExtractPid('perf')
64 self._device.old_interface.RunShellCommand( 67 self._device.old_interface.RunShellCommand(
65 'kill -SIGINT ' + ' '.join(perf_pids)) 68 'kill -SIGINT ' + ' '.join(perf_pids))
66 self._perf_process.wait() 69 self._perf_process.wait()
70 self._perf_control.ForceAllCpusOnline(False)
67 71
68 def _FailWithLog(self, msg): 72 def _FailWithLog(self, msg):
69 self._log_file.seek(0) 73 self._log_file.seek(0)
70 log = self._log_file.read() 74 log = self._log_file.read()
71 raise RuntimeError('%s. Log output:\n%s' % (msg, log)) 75 raise RuntimeError('%s. Log output:\n%s' % (msg, log))
72 76
73 def PullResult(self, output_path): 77 def PullResult(self, output_path):
74 if not self._device.old_interface.FileExistsOnDevice( 78 if not self._device.old_interface.FileExistsOnDevice(
75 self._output_file.name): 79 self._output_file.name):
76 self._FailWithLog('Perf recorded no data') 80 self._FailWithLog('Perf recorded no data')
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 perf_script_path = os.path.join(constants.DIR_SOURCE_ROOT, 155 perf_script_path = os.path.join(constants.DIR_SOURCE_ROOT,
152 'tools', 'telemetry', 'telemetry', 'core', 'platform', 'profiler', 156 'tools', 'telemetry', 'telemetry', 'core', 'platform', 'profiler',
153 'perf_vis', 'perf_to_tracing.py') 157 'perf_vis', 'perf_to_tracing.py')
154 json_file_name = os.path.basename(perf_profile) 158 json_file_name = os.path.basename(perf_profile)
155 with open(os.devnull, 'w') as dev_null, \ 159 with open(os.devnull, 'w') as dev_null, \
156 open(json_file_name, 'w') as json_file: 160 open(json_file_name, 'w') as json_file:
157 cmd = [perfhost_path, 'script', '-s', perf_script_path, '-i', 161 cmd = [perfhost_path, 'script', '-s', perf_script_path, '-i',
158 perf_profile, '--symfs', symfs_dir, '--kallsyms', kallsyms] 162 perf_profile, '--symfs', symfs_dir, '--kallsyms', kallsyms]
159 subprocess.call(cmd, stdout=json_file, stderr=dev_null) 163 subprocess.call(cmd, stdout=json_file, stderr=dev_null)
160 return json_file_name 164 return json_file_name
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/perf/perf_control.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698