summaryrefslogtreecommitdiff
path: root/automated/android/tjbench/tjbench.sh
blob: b94f42e8947cf26194ab846fb1916c80272647c7 (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/sh -e
# shellcheck disable=SC2039
# shellcheck disable=SC1091

ANDROID_SERIAL=""
BOOT_TIMEOUT="300"
OUTPUT="$(pwd)/output"
RESULT_FILE="${OUTPUT}/result.txt"
IMGS="nightshot_iso_100.ppm"
LOOPS="1"
SKIP_INSTALL="false"

. ../../lib/sh-test-lib
. ../../lib/android-test-lib

usage() {
    echo "Usage: $0 [-s <android_serial>] [-t <boot_timeout>] [-l <loops>] [-S <true|false>]" 1>&2
    exit 1
}

while getopts ":s:t:l:S:" o; do
  case "$o" in
    s) ANDROID_SERIAL="${OPTARG}" ;;
    t) BOOT_TIMEOUT="${OPTARG}" ;;
    l) LOOPS="${OPTARG}" ;;
    S) SKIP_INSTALL="${OPTARG}" ;;
    *) usage ;;
  esac
done

initialize_adb
wait_boot_completed "${BOOT_TIMEOUT}"
create_out_dir "${OUTPUT}"
install_deps "wget" "${SKIP_INSTALL}"

parse_log() {
    local logfile="$1"
    local prefix="$2_subsamp"

    grep "^RGB" "${logfile}" \
        | awk -v prefix="$prefix" \
             '{
                  gsub(":", "", $3);
                  printf("%s_%s_comp_perf pass %s Mpixels/sec\n", prefix, $3, $7);
                  printf("%s_%s_comp_ratio pass %s %\n", prefix, $3, $8);
                  printf("%s_%s_decomp_perf pass %s Mpixels/sec\n", prefix, $3, $9);
              }' \
        | tee -a "${RESULT_FILE}"
}

for test in tjbench32 tjbench64; do
    if ! adb_shell_which "${test}"; then
        report_fail "check_${test}_existence"
        exit 0
    fi
done

for img in ${IMGS}; do
    [ ! -f "./${img}" ] && \
        wget -S --progress=dot:mega "http://testdata.validation.linaro.org/tjbench/${img}"
    adb_push "./${img}" "/data/local/tmp/tjbench/"
    img_path="/data/local/tmp/tjbench/${img}"

    for test in tjbench32 tjbench64; do
        img_name="$(echo "${img}" | sed 's/[.]/_/g')"
        case "${test}" in
            tjbench32) prefix="32bit_${img_name}" ;;
            tjbench64) prefix="64bit_${img_name}" ;;
        esac

        info_msg "device-${ANDROID_SERIAL}: About to run ${test}..."
        for i in $(seq "${LOOPS}"); do
            info_msg "Running iteration [${i}/${LOOPS}]..."
            adb shell "${test} ${img_path} 95 -rgb -quiet scale 1/2" | tee -a "${OUTPUT}/${test}-w1-h2.log"
            adb shell "${test} ${img_path} 95 -rgb -quiet" | tee -a "${OUTPUT}/${test}.log"
        done
        parse_log "${OUTPUT}/${test}-w1-h2.log" "${prefix}_scale_w1_h2"
        parse_log "${OUTPUT}/${test}.log" "${prefix}"
    done
done

# Calculate min, mean and max.
if [ "${LOOPS}" -gt 2 ]; then
    tc_list=$(awk '{print $1}' "${RESULT_FILE}" | 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