From 8b2a5d7d171f58698bbcb081589d334bb7577b11 Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Tue, 20 Jan 2015 16:29:50 -0800 Subject: [PATCH] feat(perf): disable wake lock and cpu freq scaling on android --- scripts/ci/android_cpu.sh | 42 ++++++++++++++++++++++++++++++++++++++ scripts/ci/init_android.sh | 7 ++++++- scripts/ci/test_e2e.sh | 3 +++ scripts/ci/test_perf.sh | 3 +++ 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100755 scripts/ci/android_cpu.sh diff --git a/scripts/ci/android_cpu.sh b/scripts/ci/android_cpu.sh new file mode 100755 index 0000000000..24cbe47c69 --- /dev/null +++ b/scripts/ci/android_cpu.sh @@ -0,0 +1,42 @@ +#!/bin/bash +set -e + +CPUPATH=/sys/devices/system/cpu +WAKE_LOCK_NAME=ngperf + +set_governor() { + echo "Setting CPU frequency governor to \"$1\"" + adb shell 'for f in '$CPUPATH'/cpu*/cpufreq/scaling_governor ; do echo '$1' > $f; done' +} + +wake_lock() { + echo "Setting wake lock $WAKE_LOCK_NAME" + adb shell "echo $WAKE_LOCK_NAME > /sys/power/wake_lock" +} + +wake_unlock() { + echo "Removing wake lock $WAKE_LOCK_NAME" + adb shell "echo $WAKE_LOCK_NAME > /sys/power/wake_unlock" +} + +case "$1" in + (performance) + set_governor "performance" + ;; + (powersave) + set_governor "powersave" + ;; + (ondemand) + set_governor "ondemand" + ;; + (wakelock) + wake_lock + ;; + (wakeunlock) + wake_unlock + ;; + (*) + echo "Usage: $0 performance|powersave|ondemand|wakelock|wakeunlock" + exit 1 + ;; +esac diff --git a/scripts/ci/init_android.sh b/scripts/ci/init_android.sh index ca52fa2506..e4bced5507 100755 --- a/scripts/ci/init_android.sh +++ b/scripts/ci/init_android.sh @@ -1,10 +1,15 @@ #!/bin/bash set -e +SCRIPT_DIR=$(dirname $0) +cd $SCRIPT_DIR if [[ $PERF_BROWSERS =~ .*Android.* || $E2E_BROWSERS =~ .*Android.* ]] then - adb usb + adb root usb adb wait-for-device devices adb reverse tcp:8001 tcp:8001 adb reverse tcp:8002 tcp:8002 + + ./android_cpu.sh performance + ./android_cpu.sh wakelock fi diff --git a/scripts/ci/test_e2e.sh b/scripts/ci/test_e2e.sh index 6ce7964db2..b5fa3e97aa 100755 --- a/scripts/ci/test_e2e.sh +++ b/scripts/ci/test_e2e.sh @@ -18,5 +18,8 @@ serverPid=$! trap killServer EXIT +# wait for server to come up! +sleep 10 + ./node_modules/.bin/protractor protractor-e2e-js.conf.js --browsers=$E2E_BROWSERS ./node_modules/.bin/protractor protractor-e2e-dart2js.conf.js --browsers=$E2E_BROWSERS \ No newline at end of file diff --git a/scripts/ci/test_perf.sh b/scripts/ci/test_perf.sh index cd04cdcd9e..78ed851fd2 100755 --- a/scripts/ci/test_perf.sh +++ b/scripts/ci/test_perf.sh @@ -18,5 +18,8 @@ serverPid=$! trap killServer EXIT +# wait for server to come up! +sleep 10 + ./node_modules/.bin/protractor protractor-perf-js.conf.js --browsers=$PERF_BROWSERS ./node_modules/.bin/protractor protractor-perf-dart2js.conf.js --browsers=$PERF_BROWSERS \ No newline at end of file