Chromium Code Reviews| Index: build/android/pylib/perf/perf_control.py |
| diff --git a/build/android/pylib/perf/perf_control.py b/build/android/pylib/perf/perf_control.py |
| index e13c02adf8768d6560b2d8957bdae60c148da0ae..48509f3e2971ff77638965007fb0e69c33852e1f 100644 |
| --- a/build/android/pylib/perf/perf_control.py |
| +++ b/build/android/pylib/perf/perf_control.py |
| @@ -3,7 +3,6 @@ |
| # found in the LICENSE file. |
| import logging |
| -import time |
| from pylib import android_commands |
| from pylib.device import device_utils |
| @@ -21,28 +20,28 @@ class PerfControl(object): |
| if isinstance(device, android_commands.AndroidCommands): |
| device = device_utils.DeviceUtils(device) |
| self._device = device |
| - kernel_max = self._device.old_interface.GetFileContents( |
| - PerfControl._KERNEL_MAX, log_result=False) |
| - assert kernel_max, 'Unable to find %s' % PerfControl._KERNEL_MAX |
| - self._kernel_max = int(kernel_max[0]) |
| - logging.info('Maximum CPU index: %d', self._kernel_max) |
| + cpu_files = self._device.RunShellCommand( |
| + 'ls -d /sys/devices/system/cpu/cpu[0-9]*') |
| + self._num_cpu_cores = len(cpu_files) |
| + assert self._num_cpu_cores > 0 |
|
tonyg
2014/06/24 02:16:54
We should add an error message to this assert.
epennerAtGoogle
2014/06/24 02:35:57
Done.
|
| + logging.info('Number of CPUs: %d', self._num_cpu_cores) |
| self._have_mpdecision = self._device.old_interface.FileExistsOnDevice( |
| '/system/bin/mpdecision') |
| - @property |
| - def _NumCpuCores(self): |
| - return self._kernel_max + 1 |
| - |
| def SetHighPerfMode(self): |
| # TODO(epenner): Enable on all devices (http://crbug.com/383566) |
| if 'Nexus 4' == self._device.old_interface.GetProductModel(): |
| self._ForceAllCpusOnline(True) |
| + if not self._AllCpusAreOnline(): |
| + logging.warning('Failed to force CPUs online. Results may be noisy!') |
| self._SetScalingGovernorInternal('performance') |
| def SetPerfProfilingMode(self): |
| """Sets the highest possible performance mode for the device.""" |
| self._ForceAllCpusOnline(True) |
| self._SetScalingGovernorInternal('performance') |
| + if not self._AllCpusAreOnline(): |
| + raise RuntimeError('Failed to force CPUs online. Can you adb root?') |
|
tonyg
2014/06/24 02:16:54
We have methods that do this in android_commands.p
epennerAtGoogle
2014/06/24 02:35:57
The current check catches other problems, however
|
| def SetDefaultPerfMode(self): |
| """Sets the performance mode for the device to its default mode.""" |
| @@ -58,7 +57,7 @@ class PerfControl(object): |
| self._ForceAllCpusOnline(False) |
| def _SetScalingGovernorInternal(self, value): |
| - for cpu in range(self._NumCpuCores): |
| + for cpu in range(self._num_cpu_cores): |
| scaling_governor_file = PerfControl._SCALING_GOVERNOR_FMT % cpu |
| if self._device.old_interface.FileExistsOnDevice(scaling_governor_file): |
| logging.info('Writing scaling governor mode \'%s\' -> %s', |
| @@ -67,7 +66,7 @@ class PerfControl(object): |
| scaling_governor_file, value) |
| def _AllCpusAreOnline(self): |
| - for cpu in range(self._NumCpuCores): |
| + for cpu in range(self._num_cpu_cores): |
| online_path = PerfControl._CPU_ONLINE_FMT % cpu |
| if self._device.old_interface.GetFileContents(online_path)[0] == '0': |
| return False |
| @@ -97,12 +96,7 @@ class PerfControl(object): |
| if not force_online: |
| return |
| - for cpu in range(self._NumCpuCores): |
| + for cpu in range(self._num_cpu_cores): |
| online_path = PerfControl._CPU_ONLINE_FMT % cpu |
| self._device.old_interface.SetProtectedFileContents( |
| online_path, '1') |
| - |
| - # Double check all cores stayed online. |
| - time.sleep(0.25) |
| - if not self._AllCpusAreOnline(): |
| - raise RuntimeError('Failed to force CPUs online') |