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 atexit | 5 import atexit |
6 import logging | 6 import logging |
7 | 7 |
8 from pylib import android_commands | 8 from pylib import android_commands |
9 from pylib.device import device_utils | 9 from pylib.device import device_utils |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 # this will raise an AdbCommandFailedError if no CPU files are found | 21 # this will raise an AdbCommandFailedError if no CPU files are found |
22 self._cpu_files = self._device.RunShellCommand( | 22 self._cpu_files = self._device.RunShellCommand( |
23 'ls -d cpu[0-9]*', cwd=self._CPU_PATH, check_return=True, as_root=True) | 23 'ls -d cpu[0-9]*', cwd=self._CPU_PATH, check_return=True, as_root=True) |
24 assert self._cpu_files, 'Failed to detect CPUs.' | 24 assert self._cpu_files, 'Failed to detect CPUs.' |
25 self._cpu_file_list = ' '.join(self._cpu_files) | 25 self._cpu_file_list = ' '.join(self._cpu_files) |
26 logging.info('CPUs found: %s', self._cpu_file_list) | 26 logging.info('CPUs found: %s', self._cpu_file_list) |
27 self._have_mpdecision = self._device.FileExists('/system/bin/mpdecision') | 27 self._have_mpdecision = self._device.FileExists('/system/bin/mpdecision') |
28 | 28 |
29 def SetHighPerfMode(self): | 29 def SetHighPerfMode(self): |
30 """Sets the highest stable performance mode for the device.""" | 30 """Sets the highest stable performance mode for the device.""" |
31 if not self._device.HasRoot(): | 31 if not self._device.old_interface.IsRootEnabled(): |
32 message = 'Need root for performance mode. Results may be NOISY!!' | 32 message = 'Need root for performance mode. Results may be NOISY!!' |
33 logging.warning(message) | 33 logging.warning(message) |
34 # Add an additional warning at exit, such that it's clear that any results | 34 # Add an additional warning at exit, such that it's clear that any results |
35 # may be different/noisy (due to the lack of intended performance mode). | 35 # may be different/noisy (due to the lack of intended performance mode). |
36 atexit.register(logging.warning, message) | 36 atexit.register(logging.warning, message) |
37 return | 37 return |
38 | 38 |
39 product_model = self._device.product_model | 39 product_model = self._device.product_model |
40 # TODO(epenner): Enable on all devices (http://crbug.com/383566) | 40 # TODO(epenner): Enable on all devices (http://crbug.com/383566) |
41 if 'Nexus 4' == product_model: | 41 if 'Nexus 4' == product_model: |
42 self._ForceAllCpusOnline(True) | 42 self._ForceAllCpusOnline(True) |
43 if not self._AllCpusAreOnline(): | 43 if not self._AllCpusAreOnline(): |
44 logging.warning('Failed to force CPUs online. Results may be NOISY!') | 44 logging.warning('Failed to force CPUs online. Results may be NOISY!') |
45 self._SetScalingGovernorInternal('performance') | 45 self._SetScalingGovernorInternal('performance') |
46 elif 'Nexus 5' == product_model: | 46 elif 'Nexus 5' == product_model: |
47 self._ForceAllCpusOnline(True) | 47 self._ForceAllCpusOnline(True) |
48 if not self._AllCpusAreOnline(): | 48 if not self._AllCpusAreOnline(): |
49 logging.warning('Failed to force CPUs online. Results may be NOISY!') | 49 logging.warning('Failed to force CPUs online. Results may be NOISY!') |
50 self._SetScalingGovernorInternal('performance') | 50 self._SetScalingGovernorInternal('performance') |
51 self._SetScalingMaxFreq(1190400) | 51 self._SetScalingMaxFreq(1190400) |
52 self._SetMaxGpuClock(200000000) | 52 self._SetMaxGpuClock(200000000) |
53 else: | 53 else: |
54 self._SetScalingGovernorInternal('performance') | 54 self._SetScalingGovernorInternal('performance') |
55 | 55 |
56 def SetPerfProfilingMode(self): | 56 def SetPerfProfilingMode(self): |
57 """Enables all cores for reliable perf profiling.""" | 57 """Enables all cores for reliable perf profiling.""" |
58 self._ForceAllCpusOnline(True) | 58 self._ForceAllCpusOnline(True) |
59 self._SetScalingGovernorInternal('performance') | 59 self._SetScalingGovernorInternal('performance') |
60 if not self._AllCpusAreOnline(): | 60 if not self._AllCpusAreOnline(): |
61 if not self._device.HasRoot(): | 61 if not self._device.old_interface.IsRootEnabled(): |
62 raise RuntimeError('Need root to force CPUs online.') | 62 raise RuntimeError('Need root to force CPUs online.') |
63 raise RuntimeError('Failed to force CPUs online.') | 63 raise RuntimeError('Failed to force CPUs online.') |
64 | 64 |
65 def SetDefaultPerfMode(self): | 65 def SetDefaultPerfMode(self): |
66 """Sets the performance mode for the device to its default mode.""" | 66 """Sets the performance mode for the device to its default mode.""" |
67 if not self._device.HasRoot(): | 67 if not self._device.old_interface.IsRootEnabled(): |
68 return | 68 return |
69 product_model = self._device.product_model | 69 product_model = self._device.product_model |
70 if 'Nexus 5' == product_model: | 70 if 'Nexus 5' == product_model: |
71 if self._AllCpusAreOnline(): | 71 if self._AllCpusAreOnline(): |
72 self._SetScalingMaxFreq(2265600) | 72 self._SetScalingMaxFreq(2265600) |
73 self._SetMaxGpuClock(450000000) | 73 self._SetMaxGpuClock(450000000) |
74 | 74 |
75 governor_mode = { | 75 governor_mode = { |
76 'GT-I9300': 'pegasusq', | 76 'GT-I9300': 'pegasusq', |
77 'Galaxy Nexus': 'interactive', | 77 'Galaxy Nexus': 'interactive', |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 """ | 148 """ |
149 if self._have_mpdecision: | 149 if self._have_mpdecision: |
150 script = 'stop mpdecision' if force_online else 'start mpdecision' | 150 script = 'stop mpdecision' if force_online else 'start mpdecision' |
151 self._device.RunShellCommand(script, check_return=True, as_root=True) | 151 self._device.RunShellCommand(script, check_return=True, as_root=True) |
152 | 152 |
153 if not self._have_mpdecision and not self._AllCpusAreOnline(): | 153 if not self._have_mpdecision and not self._AllCpusAreOnline(): |
154 logging.warning('Unexpected cpu hot plugging detected.') | 154 logging.warning('Unexpected cpu hot plugging detected.') |
155 | 155 |
156 if force_online: | 156 if force_online: |
157 self._ForEachCpu('echo 1 > "$CPU/online"') | 157 self._ForEachCpu('echo 1 > "$CPU/online"') |
OLD | NEW |