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

Unified Diff: build/android/pylib/perf_tests_helper.py

Issue 23681011: Android: splits cache_control and perf_control. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
Index: build/android/pylib/perf_tests_helper.py
diff --git a/build/android/pylib/perf_tests_helper.py b/build/android/pylib/perf_tests_helper.py
index 23ce858a4bfd516b21ed748970ac94731fbdd251..58e89d088176b3620a30cf72f0254ae04642f1f4 100644
--- a/build/android/pylib/perf_tests_helper.py
+++ b/build/android/pylib/perf_tests_helper.py
@@ -6,6 +6,8 @@ import re
import sys
import android_commands
+import cache_control
+import perf_control
import json
import logging
import math
@@ -146,58 +148,11 @@ def PrintPerfResult(measurement, trace, values, units, result_type='default',
return output
-class CacheControl(object):
- _DROP_CACHES = '/proc/sys/vm/drop_caches'
-
+# TODO(bulach): remove once all references to PerfControl are fixed.
+class CacheControl(cache_control.CacheControl):
def __init__(self, adb):
- self._adb = adb
-
- def DropRamCaches(self):
- """Drops the filesystem ram caches for performance testing."""
- self._adb.RunShellCommand('su -c sync')
- self._adb.SetProtectedFileContents(CacheControl._DROP_CACHES, '3')
-
-
-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')
+ super(CacheControl, self).__init__(adb)
+class PerfControl(perf_control.PerfControl):
def __init__(self, adb):
- self._adb = adb
- kernel_max = self._adb.GetFileContents('/sys/devices/system/cpu/kernel_max',
- log_result=False)
- assert kernel_max, 'Unable to find /sys/devices/system/cpu/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)
+ super(PerfControl, self).__init__(adb)

Powered by Google App Engine
This is Rietveld 408576698