summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChase Qi <chase.qi@linaro.org>2017-03-24 17:43:37 +0800
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2017-03-27 13:25:14 +0000
commit5789b1758f4052c9114464109acabf7494959928 (patch)
treef1f8fa2330bd662fb23ae4eca3e55a26c9b1f7d6
parent34f694a06a0ba2fac36d50cea50dda6d2215afc5 (diff)
automated: android: add libc-bench test
Change-Id: I97fd652fa88f70a873433012ff34618c400b3769 Signed-off-by: Chase Qi <chase.qi@linaro.org>
-rwxr-xr-xautomated/android/libc-bench/libc-bench.sh97
-rw-r--r--automated/android/libc-bench/libc-bench.yaml29
2 files changed, 126 insertions, 0 deletions
diff --git a/automated/android/libc-bench/libc-bench.sh b/automated/android/libc-bench/libc-bench.sh
new file mode 100755
index 0000000..78f4054
--- /dev/null
+++ b/automated/android/libc-bench/libc-bench.sh
@@ -0,0 +1,97 @@
+#!/bin/sh -e
+
+OUTPUT="$(pwd)/output"
+RESULT_FILE="${OUTPUT}/result.txt"
+export RESULT_FILE
+ANDROID_SERIAL=""
+BOOT_TIMEOUT="300"
+LOOPS="1"
+
+usage() {
+ echo "Usage: $0 [-s <android_serial>] [-t <boot_timeout>] [-l <loops>]" 1>&2
+ exit 1
+}
+
+while getopts ":s:t:l:" o; do
+ case "$o" in
+ # Specify device serial number when more than one device connected.
+ s) ANDROID_SERIAL="${OPTARG}" ;;
+ t) BOOT_TIMEOUT="${OPTARG}" ;;
+ l) LOOPS="${OPTARG}" ;;
+ *) usage ;;
+ esac
+done
+
+# shellcheck disable=SC1091
+. ../../lib/sh-test-lib
+# shellcheck disable=SC1091
+. ../../lib/android-test-lib
+
+initialize_adb
+wait_boot_completed "${BOOT_TIMEOUT}"
+create_out_dir "${OUTPUT}"
+
+parse_log() {
+ case "${test}" in
+ libcbench) prefix="32bit" ;;
+ libcbench64) prefix="64bit" ;;
+ esac
+
+ while read -r line; do
+ # Parse test case id line.
+ if echo "${line}" | grep -q "^b_"; then
+ tc="${prefix}_$(echo "${line}" | tr -c '[:alnum:]' '_' | tr -s '_' | sed 's/_$//')"
+ fi
+
+ # Parse the following value line.
+ if echo "${line}" | grep -q '^time:'; then
+ time=$(echo "${line}" | awk '{print $2}' | sed 's/,//')
+ add_metric "${tc}_time" "pass" "${time}" "seconds"
+
+ virt=$(echo "${line}" | awk '{print $4}'| sed 's/,//')
+ add_metric "${tc}_virt" "pass" "${virt}" "KB"
+
+ res=$(echo "${line}" | awk '{print $6}'| sed 's/,//')
+ add_metric "${tc}_res" "pass" "${res}" "KB"
+
+ dirty=$(echo "${line}" | awk '{print $8}')
+ add_metric "${tc}_dirty" "pass" "${dirty}" "KB"
+ fi
+ done < "${logfile}"
+}
+
+for test in libcbench libcbench64; do
+ if ! adb_shell_which "${test}"; then
+ report_fail "check-${test}-existence"
+ exit 0
+ fi
+
+ info_msg "device-${ANDROID_SERIAL}: About to run ${test}..."
+ for i in $(seq "${LOOPS}"); do
+ info_msg "Running iteration [${i}/${LOOPS}]..."
+ logfile="${OUTPUT}/${test}-$i.log"
+ adb shell "${test}" | tee "${logfile}"
+ parse_log
+ done
+done
+
+# Calculate min, mean and max for 'time' metric.
+if [ "${LOOPS}" -gt 2 ]; then
+ tc_list=$(awk '{print $1}' "${RESULT_FILE}" | grep "time" | sort -u)
+ for tc in ${tc_list}; do
+ grep "$tc" "${RESULT_FILE}" \
+ | awk -v tc="${tc}" \
+ '{
+ if(min=="") {min=max=$3};
+ if($3>max) {max=$3};
+ if($3< min) {min=$3};
+ total+=$3; count+=1;
+ }
+ END {
+ printf("%s-min pass %s %s\n", tc, min, $4);
+ printf("%s-mean pass %s %s\n", tc, total/count, $4);
+ printf("%s-max pass %s %s\n", tc, max, $4)
+ }' \
+ | tee -a "${RESULT_FILE}"
+ done
+fi
diff --git a/automated/android/libc-bench/libc-bench.yaml b/automated/android/libc-bench/libc-bench.yaml
new file mode 100644
index 0000000..ddc9237
--- /dev/null
+++ b/automated/android/libc-bench/libc-bench.yaml
@@ -0,0 +1,29 @@
+metadata:
+ name: libc-bench
+ format: "Lava-Test-Shell Test Definition 1.0"
+ description: "Run libc-bench to benchmark the performance of bionic.
+ The source can be viewed here:
+ https://android-git.linaro.org/platform/external/libc-bench"
+ maintainer:
+ - yongqin.liu@linaro.org
+ - chase.qi@linaro.org
+ os:
+ - android
+ scope:
+ - performance
+ devices:
+ - juno
+ - hi6220-hikey
+
+params:
+ # Specify device serial no. when more than one device connected.
+ ANDROID_SERIAL: ""
+ # Specify timeout in seconds for wait_boot_completed
+ BOOT_TIMEOUT: "300"
+ LOOPS: "1"
+
+run:
+ steps:
+ - cd ./automated/android/libc-bench
+ - ./libc-bench.sh -s "${ANDROID_SERIAL}" -t "${BOOT_TIMEOUT}" -l "${LOOPS}"
+ - ../../utils/send-to-lava.sh ./output/result.txt