blob: ae6a618bc8dbd699c381c3b4aea2b2602f057d98 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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 <loops count>]" 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
|