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

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

Issue 10914199: Android: upstream latest changes for build/android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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/constants.py ('k') | build/android/pylib/run_java_tests.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 193442ede9dd1df3783defe5fbe1cac45856404e..19c24f3f7f55f3fb62d8af936a8f3672fcc5fd5a 100644
--- a/build/android/pylib/perf_tests_helper.py
+++ b/build/android/pylib/perf_tests_helper.py
@@ -4,6 +4,7 @@
import re
+import android_commands
# Valid values of result type.
RESULT_TYPES = {'unimportant': 'RESULT ',
@@ -69,3 +70,41 @@ def PrintPerfResult(measurement, trace, values, units, result_type='default',
if print_to_stdout:
print output
return output
+
+
+class PerfTestSetup(object):
+ """Provides methods for setting up a device for perf testing."""
+ _DROP_CACHES = '/proc/sys/vm/drop_caches'
+ _SCALING_GOVERNOR = '/sys/devices/system/cpu/cpu%d/cpufreq/scaling_governor'
+
+ def __init__(self, adb):
+ self._adb = adb
+ num_cpus = self._adb.GetFileContents('/sys/devices/system/cpu/online',
+ log_result=False)
+ assert num_cpus, 'Unable to find /sys/devices/system/cpu/online'
+ self._num_cpus = int(num_cpus[0].split('-')[-1])
+ self._original_scaling_governor = None
+
+ def DropRamCaches(self):
+ """Drops the filesystem ram caches for performance testing."""
+ self._adb.RunShellCommand('echo 3 > ' + PerfTestSetup._DROP_CACHES)
+
+ def SetUp(self):
+ """Sets up performance tests."""
+ if not self._original_scaling_governor:
+ self._original_scaling_governor = self._adb.GetFileContents(
+ PerfTestSetup._SCALING_GOVERNOR % 0,
+ log_result=False)[0]
+ self._SetScalingGovernorInternal('performance')
+ self.DropRamCaches()
+
+ def TearDown(self):
+ """Tears down performance tests."""
+ if self._original_scaling_governor:
+ self._SetScalingGovernorInternal(self._original_scaling_governor)
+ self._original_scaling_governor = None
+
+ def _SetScalingGovernorInternal(self, value):
+ for cpu in range(self._num_cpus):
+ self._adb.RunShellCommand(
+ ('echo %s > ' + PerfTestSetup._SCALING_GOVERNOR) % (value, cpu))
« no previous file with comments | « build/android/pylib/constants.py ('k') | build/android/pylib/run_java_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698