diff options
author | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-11 15:41:56 +0000 |
---|---|---|
committer | bulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-11 15:41:56 +0000 |
commit | 117cae2668f9004d64df74a642591d41f6bfef2b (patch) | |
tree | 8bac2070ce22ef875628773d717fd858caf4aa58 /build/android/pylib/perf_tests_helper.py | |
parent | 3ac8b1c27bd58b0476648678f076150ff60a8713 (diff) | |
download | chromium_src-117cae2668f9004d64df74a642591d41f6bfef2b.zip chromium_src-117cae2668f9004d64df74a642591d41f6bfef2b.tar.gz chromium_src-117cae2668f9004d64df74a642591d41f6bfef2b.tar.bz2 |
Android: upstream latest changes for build/android.
- uses $EXTERNAL_STORAGE rather than /sdcard
- split PerfTEstSetup from android_commands.py
BUG=
TEST=
Review URL: https://chromiumcodereview.appspot.com/10914199
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156017 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build/android/pylib/perf_tests_helper.py')
-rw-r--r-- | build/android/pylib/perf_tests_helper.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/build/android/pylib/perf_tests_helper.py b/build/android/pylib/perf_tests_helper.py index 193442e..19c24f3 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)) |