From 7d7ec4d7829808bbb10858729912ad3ed2733289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20D=C3=ADaz?= Date: Sat, 18 Feb 2017 08:11:19 -0600 Subject: automated: add bionic-benchmarks test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ic2714900764a4d0a13864f5feb4a85c8ef54afc0 Signed-off-by: Daniel Díaz --- .../android/bionic-benchmarks/bionic-benchmarks.sh | 79 ++++++++++++++++++++++ .../bionic-benchmarks/bionic-benchmarks.yaml | 25 +++++++ .../android/bionic-benchmarks/device-script.sh | 45 ++++++++++++ 3 files changed, 149 insertions(+) create mode 100755 automated/android/bionic-benchmarks/bionic-benchmarks.sh create mode 100755 automated/android/bionic-benchmarks/bionic-benchmarks.yaml create mode 100755 automated/android/bionic-benchmarks/device-script.sh (limited to 'automated') diff --git a/automated/android/bionic-benchmarks/bionic-benchmarks.sh b/automated/android/bionic-benchmarks/bionic-benchmarks.sh new file mode 100755 index 0000000..ae6a618 --- /dev/null +++ b/automated/android/bionic-benchmarks/bionic-benchmarks.sh @@ -0,0 +1,79 @@ +#!/bin/sh + +HOST_OUTPUT="$(pwd)/output" +DEVICE_OUTPUT="/data/local/tmp/result_unsorted.txt" +RESULT_FILE="${HOST_OUTPUT}/result.txt" +export RESULT_FILE +LOOPS=1 +TIMEOUT=300 + +usage() { + echo "Usage: $0 [-l ]" 1>&2 + exit 1 +} + +report_test() { + test_key=$1 sum=$2 loops=$3 units=$4 + + avg=$((sum / loops)) + echo "${test_key} pass ${avg} ${units}" +} + +consolidate_results() { + # Sort timed tests by name + grep _time "${HOST_OUTPUT}/result_unsorted.txt" | sort > "${HOST_OUTPUT}/result_sorted.txt" + + # Count and calculate average for each timed test + while read -r testres; do + test=$(echo "${testres}" | awk '{print $1}') + value=$(echo "${testres}" | awk '{print $3}') + units=$(echo "${testres}" | awk '{print $4}') + + if [ "${test}" != "${curr_test}" ]; then + if [ -n "${curr_test}" ]; then + report_test "${curr_test}" "${sum}" "${LOOPS}" "${units}" >> \ + "${RESULT_FILE}" + fi + curr_test="${test}" + sum=${value} + else + sum=$((sum + value)) + fi + done < "${HOST_OUTPUT}/result_sorted.txt" + # Last test from the loop: + report_test "${curr_test}" "${sum}" "${LOOPS}" "${units}" >> "${RESULT_FILE}" + + # Add non-timed tests to result.txt + grep -v _time "${HOST_OUTPUT}/result_unsorted.txt" | sort -u >> "${RESULT_FILE}" +} + +while getopts "l:" o; do + case "$o" in + # Number of times the benchmarks will run. + l) LOOPS="${OPTARG}" ;; + *) usage ;; + esac +done + +# shellcheck disable=SC1091 +. ../../lib/sh-test-lib +. ../../lib/android-test-lib + +# Test run. +create_out_dir "${HOST_OUTPUT}" + +initialize_adb +wait_boot_completed "${TIMEOUT}" +adb_push "./device-script.sh" "/data/local/tmp/" + +info_msg "About to run bionic-benchmarks on device ${SN}" +adb -s "${SN}" shell /data/local/tmp/device-script.sh "${LOOPS}" 2>&1 \ + | tee "${HOST_OUTPUT}"/device-run.log + +adb_pull "${DEVICE_OUTPUT}" "${HOST_OUTPUT}" + +if [ "${LOOPS}" -gt 1 ]; then + consolidate_results +else + cp -p "${HOST_OUTPUT}/result_unsorted.txt" "${RESULT_FILE}" +fi diff --git a/automated/android/bionic-benchmarks/bionic-benchmarks.yaml b/automated/android/bionic-benchmarks/bionic-benchmarks.yaml new file mode 100755 index 0000000..ca98a2d --- /dev/null +++ b/automated/android/bionic-benchmarks/bionic-benchmarks.yaml @@ -0,0 +1,25 @@ +metadata: + name: bionic-benchmarks-with-units + format: "Lava-Test-Shell Test Definition 1.0" + description: "Collect the bionic-benchmarks data and try to analyse it." + maintainer: + - daniel.diaz@linaro.org + os: + - android + devices: + - juno + - hi6220-hikey + - x15 + scope: + - performance + environment: + - lava-test-shell + +params: + LOOPS: "1" + +run: + steps: + - cd ./automated/linux/bionic-benchmarks/ + - ./bionic-benchmarks.sh -l "${LOOPS}" + - ../../utils/send-to-lava.sh ./output/result.txt diff --git a/automated/android/bionic-benchmarks/device-script.sh b/automated/android/bionic-benchmarks/device-script.sh new file mode 100755 index 0000000..5c64456 --- /dev/null +++ b/automated/android/bionic-benchmarks/device-script.sh @@ -0,0 +1,45 @@ +#!/system/bin/sh + +OUTPUT_FILE="/data/local/tmp/result_unsorted.txt" + +test_bionic_benchmark() { + tbb_arch=$1 + cmd="" + if [ "X$tbb_arch" = "X32" ]; then + cmd="/data/benchmarktest/bionic-benchmarks/bionic-benchmarks32" + elif [ "X$tbb_arch" = "X64" ]; then + cmd="/data/benchmarktest/bionic-benchmarks/bionic-benchmarks64" + else + echo "The specified arch ($tbb_arch) is not supported!" + return + fi + chmod +x ${cmd} ||: + if [ -x "${cmd}" ]; then + for res_line in $(${cmd} |grep "BM_"|tr -s ' '|tr ' ' ','); do + tbb_key=$(echo "$res_line"|cut -d, -f1|tr '/' '_') + #tbb_iterations=$(echo "$res_line"|cut -d, -f2) + tbb_ns_time=$(echo "$res_line"|cut -d, -f3) + tbb_throughput=$(echo "$res_line"|cut -d, -f4) + tbb_throughput_units=$(echo "$res_line"|cut -d, -f5) + echo "${tbb_arch}_${tbb_key}" "pass" >> "${OUTPUT_FILE}" + echo "${tbb_arch}_${tbb_key}_time" "pass" "${tbb_ns_time}" "ns/op" >> "${OUTPUT_FILE}" + if [ -n "${tbb_throughput_units}" ]; then + echo "${tbb_arch}_${tbb_key}_throughput" "pass" "${tbb_throughput}" "${tbb_throughput_units}" >> "${OUTPUT_FILE}" + fi + done + else + echo "Can't execute ${cmd}!" + return + fi +} + +: > "${OUTPUT_FILE}" +loops=1 +[ $# -gt 0 ] && loops=$1 +i=1 +until [ ${i} -gt "${loops}" ]; do + echo "Run ${i}..." + test_bionic_benchmark "64" + test_bionic_benchmark "32" + i=$((i + 1)) +done -- cgit v1.2.3