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

Side by Side Diff: build/android/pylib/perf_tests_helper.py

Issue 16357016: AndroidParf: log max CPU index when running tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 re 5 import re
6 import sys 6 import sys
7 7
8 import android_commands 8 import android_commands
9 import json 9 import json
10 import logging
10 import math 11 import math
11 12
12 # Valid values of result type. 13 # Valid values of result type.
13 RESULT_TYPES = {'unimportant': 'RESULT ', 14 RESULT_TYPES = {'unimportant': 'RESULT ',
14 'default': '*RESULT ', 15 'default': '*RESULT ',
15 'informational': '', 16 'informational': '',
16 'unimportant-histogram': 'HISTOGRAM ', 17 'unimportant-histogram': 'HISTOGRAM ',
17 'histogram': '*HISTOGRAM '} 18 'histogram': '*HISTOGRAM '}
18 19
19 20
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 146
146 147
147 class PerfControl(object): 148 class PerfControl(object):
148 """Provides methods for setting the performance mode of a device.""" 149 """Provides methods for setting the performance mode of a device."""
149 _SCALING_GOVERNOR_FMT = ( 150 _SCALING_GOVERNOR_FMT = (
150 '/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor') 151 '/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor')
151 152
152 def __init__(self, adb): 153 def __init__(self, adb):
153 self._adb = adb 154 self._adb = adb
154 kernel_max = self._adb.GetFileContents('/sys/devices/system/cpu/kernel_max', 155 kernel_max = self._adb.GetFileContents('/sys/devices/system/cpu/kernel_max',
155 log_result=False) 156 log_result=False)
156 assert kernel_max, 'Unable to find /sys/devices/system/cpu/kernel_max' 157 assert kernel_max, 'Unable to find /sys/devices/system/cpu/kernel_max'
157 self._kernel_max = int(kernel_max[0]) 158 self._kernel_max = int(kernel_max[0])
159 logging.info('Maximum CPU index: %d' % self._kernel_max)
158 self._original_scaling_governor = self._adb.GetFileContents( 160 self._original_scaling_governor = self._adb.GetFileContents(
159 PerfControl._SCALING_GOVERNOR_FMT % 0, 161 PerfControl._SCALING_GOVERNOR_FMT % 0,
160 log_result=False)[0] 162 log_result=False)[0]
161 163
162 def SetHighPerfMode(self): 164 def SetHighPerfMode(self):
163 """Sets the highest possible performance mode for the device.""" 165 """Sets the highest possible performance mode for the device."""
164 self._SetScalingGovernorInternal('performance') 166 self._SetScalingGovernorInternal('performance')
165 167
166 def SetDefaultPerfMode(self): 168 def SetDefaultPerfMode(self):
167 """Sets the performance mode for the device to its default mode.""" 169 """Sets the performance mode for the device to its default mode."""
168 product_model = self._adb.GetProductModel() 170 product_model = self._adb.GetProductModel()
169 governor_mode = { 171 governor_mode = {
170 "GT-I9300" : 'pegasusq', 172 "GT-I9300" : 'pegasusq',
171 "Galaxy Nexus" : 'interactive', 173 "Galaxy Nexus" : 'interactive',
172 "Nexus 4" : 'ondemand', 174 "Nexus 4" : 'ondemand',
173 "Nexus 7" : 'interactive', 175 "Nexus 7" : 'interactive',
174 "Nexus 10": 'interactive' 176 "Nexus 10": 'interactive'
175 }.get(product_model, 'ondemand') 177 }.get(product_model, 'ondemand')
176 self._SetScalingGovernorInternal(governor_mode) 178 self._SetScalingGovernorInternal(governor_mode)
177 179
178 def RestoreOriginalPerfMode(self): 180 def RestoreOriginalPerfMode(self):
179 """Resets the original performance mode of the device.""" 181 """Resets the original performance mode of the device."""
180 self._SetScalingGovernorInternal(self._original_scaling_governor) 182 self._SetScalingGovernorInternal(self._original_scaling_governor)
181 183
182 def _SetScalingGovernorInternal(self, value): 184 def _SetScalingGovernorInternal(self, value):
183 for cpu in range(self._kernel_max + 1): 185 for cpu in range(self._kernel_max + 1):
184 scaling_governor_file = PerfControl._SCALING_GOVERNOR_FMT % cpu 186 scaling_governor_file = PerfControl._SCALING_GOVERNOR_FMT % cpu
185 if self._adb.FileExistsOnDevice(scaling_governor_file): 187 if self._adb.FileExistsOnDevice(scaling_governor_file):
188 logging.info('Writing scaling governor mode \'%s\' -> %s' %
189 (value, scaling_governor_file))
186 self._adb.SetProtectedFileContents(scaling_governor_file, value) 190 self._adb.SetProtectedFileContents(scaling_governor_file, value)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698