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

Unified Diff: build/android/pylib/perf/perf_control.py

Issue 23681011: Android: splits cache_control and perf_control. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More files Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/pylib/perf/cache_control.py ('k') | build/android/pylib/perf/surface_stats_collector.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
new file mode 100644
index 0000000000000000000000000000000000000000..e289991f84abd918780ce520db4467e3ceb5ec64
--- /dev/null
+++ b/build/android/pylib/perf/perf_control.py
@@ -0,0 +1,52 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+import logging
+
+
+class PerfControl(object):
+ """Provides methods for setting the performance mode of a device."""
+ _SCALING_GOVERNOR_FMT = (
+ '/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor')
+ _KERNEL_MAX = '/sys/devices/system/cpu/kernel_max'
+
+ def __init__(self, adb):
+ self._adb = adb
+ kernel_max = self._adb.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)
+ self._original_scaling_governor = self._adb.GetFileContents(
+ PerfControl._SCALING_GOVERNOR_FMT % 0,
+ log_result=False)[0]
+
+ def SetHighPerfMode(self):
+ """Sets the highest possible performance mode for the device."""
+ self._SetScalingGovernorInternal('performance')
+
+ def SetDefaultPerfMode(self):
+ """Sets the performance mode for the device to its default mode."""
+ product_model = self._adb.GetProductModel()
+ governor_mode = {
+ 'GT-I9300': 'pegasusq',
+ 'Galaxy Nexus': 'interactive',
+ 'Nexus 4': 'ondemand',
+ 'Nexus 7': 'interactive',
+ 'Nexus 10': 'interactive'
+ }.get(product_model, 'ondemand')
+ self._SetScalingGovernorInternal(governor_mode)
+
+ def RestoreOriginalPerfMode(self):
+ """Resets the original performance mode of the device."""
+ self._SetScalingGovernorInternal(self._original_scaling_governor)
+
+ def _SetScalingGovernorInternal(self, value):
+ for cpu in range(self._kernel_max + 1):
+ scaling_governor_file = PerfControl._SCALING_GOVERNOR_FMT % cpu
+ if self._adb.FileExistsOnDevice(scaling_governor_file):
+ logging.info('Writing scaling governor mode \'%s\' -> %s',
+ value, scaling_governor_file)
+ self._adb.SetProtectedFileContents(scaling_governor_file, value)
« no previous file with comments | « build/android/pylib/perf/cache_control.py ('k') | build/android/pylib/perf/surface_stats_collector.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698