diff options
author | Yongqin Liu <yongqin.liu@linaro.org> | 2017-09-19 00:16:39 +0800 |
---|---|---|
committer | Yongqin Liu <yongqin.liu@linaro.org> | 2017-09-19 00:20:18 +0800 |
commit | 3b909a25058e66157d7239fe559530ee5de0e0f5 (patch) | |
tree | f4d8f2e3a8ea4b5dd40151769c3203e8b8ce7831 | |
parent | b3f4ff288279cd5dff53274071709ccdca3a8555 (diff) |
android apk-automation: set governor to performance
before start the benchmark applications
Change-Id: I38d6d2dc6cc022066c5295786f7a060ee5ef5628
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
-rwxr-xr-x | automated/android/apk-automation/common/__init__.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/automated/android/apk-automation/common/__init__.py b/automated/android/apk-automation/common/__init__.py index 45e95bb..f0bd962 100755 --- a/automated/android/apk-automation/common/__init__.py +++ b/automated/android/apk-automation/common/__init__.py @@ -252,7 +252,41 @@ class ApkTestRunner(object): self.call_adb('logcat -d -b events -v time > %s/logcat-events.log' % self.config['output']) self.call_adb('shell dmesg > %s/dmesg.log' % self.config['output']) + def set_performance_governor(self, target_governor="performance"): + f_scaling_governor = ('/sys/devices/system/cpu/' + 'cpu0/cpufreq/scaling_governor') + f_governor_backup = '/data/local/tmp/scaling_governor' + dir_sys_cpu = '/sys/devices/system/cpu/' + self.call_adb('shell "cat %s>%s"' % (f_scaling_governor, + f_governor_backup)) + + f_cpus_remote = '/data/local/tmp/cpus.txt' + self.call_adb('shell "ls -d %s/cpu[0-9]* >%s"' % (dir_sys_cpu, + f_cpus_remote)) + f_cpus_local = os.path.join(os.path.abspath(self.config['output']), + 'cpus.txt') + self.call_adb('pull %s %s' % (f_cpus_remote, f_cpus_local)) + with open(f_cpus_local, 'r') as f: + for cpu in f.readlines(): + self.call_adb('shell "echo %s>%s/cpufreq/' + 'scaling_governor"' % (target_governor, + cpu.strip())) + + def set_back_governor(self): + dir_sys_cpu = '/sys/devices/system/cpu/' + f_governor_backup = '/data/local/tmp/scaling_governor' + f_governor_local = os.path.join(os.path.abspath(self.config['output']), + 'scaling_governor') + self.call_adb('pull %s %s' % (f_governor_backup, f_governor_local)) + with open(f_governor_local, 'r') as f: + contents = f.readlines() + if len(contents) > 0: + gov_policy = contents[0].strip() + self.set_performance_governor(target_governor=gov_policy) + def setUp(self): + # set to peformance governor policay + self.set_performance_governor() # Install APK. self.download_apk(self.config['apk_file_name']) self.uninstall_apk(self.config['apk_package']) @@ -275,3 +309,4 @@ class ApkTestRunner(object): def tearDown(self): self.uninstall_apk(self.config['apk_package']) + self.set_back_governor() |