diff options
author | Chase Qi <chase.qi@linaro.org> | 2016-10-21 15:22:13 +0800 |
---|---|---|
committer | Milosz Wasilewski <milosz.wasilewski@linaro.org> | 2016-10-27 11:27:39 +0000 |
commit | 3864dbf0b33f31a88b66811ab3eb527f6fc3df35 (patch) | |
tree | 0e1f42e7fd7cd91616056fd9c1c63a32e28db7ac /automated | |
parent | 8c4bfe3eb387760bd59e876440d3273f20d67470 (diff) |
v2: linux: add device read performance test
Use 'hdparm -t' to perform timings of block device reads for
benchmark and comparison purposes
Change-Id: I8dbefc4c4b4ba5fb539cd6a3df037ff43666a45a
Signed-off-by: Chase Qi <chase.qi@linaro.org>
Diffstat (limited to 'automated')
-rwxr-xr-x | automated/linux/device-read-perf/device-read-perf.sh | 60 | ||||
-rw-r--r-- | automated/linux/device-read-perf/device-read-perf.yaml | 30 |
2 files changed, 90 insertions, 0 deletions
diff --git a/automated/linux/device-read-perf/device-read-perf.sh b/automated/linux/device-read-perf/device-read-perf.sh new file mode 100755 index 0000000..dd00a2d --- /dev/null +++ b/automated/linux/device-read-perf/device-read-perf.sh @@ -0,0 +1,60 @@ +#!/bin/sh -e + +. ../../lib/sh-test-lib +OUTPUT="$(pwd)/output" +RESULT_FILE="${OUTPUT}/result.txt" +export RESULT_FILE + +usage() { + echo "Usage: $0 [-d <sda|mmcblk0>] [-s <true|false>]" 1>&2 + exit 1 +} + +while getopts "d:s:" o; do + case "$o" in + d) device_list="${OPTARG}" ;; + s) SKIP_INSTALL="${OPTARG}" ;; + *) usage ;; + esac +done + +! check_root && error_msg "You need to be root to run this script." +[ -d "${OUTPUT}" ] && mv "${OUTPUT}" "${OUTPUT}_$(date +%Y%m%d%H%M%S)" +mkdir -p "${OUTPUT}" + +install_deps "hdparm" "${SKIP_INSTALL}" + +# Test all block devices if device not specified. +if [ -z "${device_list}" ]; then + if lsblk | egrep "^(sd|hd|mmcblk)[a-z0-9] "; then + device_list=$(lsblk \ + | egrep "^(sd|hd|mmcblk)[a-z0-9] " \ + | awk '{print $1}') + else + error_msg "Block device NOT found" + fi +fi + +# Test run. +# 'hdparm -t' should be repeated 2-3 times for meaningful result. +for device in ${device_list}; do + echo + sum=0 + for i in $(seq 3); do + info_msg "Running iteration $i on /dev/${device}" + output_file="${OUTPUT}/${device}-iteration$i-output.txt" + hdparm -t /dev/"${device}" > "${output_file}" 2>&1 + result=$(grep "reads" "${output_file}" | awk '{print $(NF-1)}') + units=$(grep "reads" "${output_file}" | awk '{print substr($NF, 1, 2)}') + + # Convert result to MB when units isn't MB. + result=$(convert_to_mb "${result}" "${units}") + + echo "Device read timings: ${result} MB/sec" + sum=$(echo "${sum} ${result}" | awk '{print $1+$2}') + done + + result_avg=$(echo "${sum}" | awk '{print $1/3}') + echo "${device} average read timings: ${result_avg}" + add_metric "${device}-read-perf" "pass" "${result_avg}" "MB/sec" +done diff --git a/automated/linux/device-read-perf/device-read-perf.yaml b/automated/linux/device-read-perf/device-read-perf.yaml new file mode 100644 index 0000000..d66c787 --- /dev/null +++ b/automated/linux/device-read-perf/device-read-perf.yaml @@ -0,0 +1,30 @@ +metadata: + format: Lava-Test Test Definition 1.0 + name: device-read-perf + description: "Use 'hdparm -t' to perform timings of block device reads for + benchmark and comparison purposes." + maintainer: + - chase.qi@linaro.org + os: + - debian + - ubuntu + - fedora + - centos + scope: + - performance + devices: + - mustang + - d03 + - d05 + - ifc6410 + +params: + # Specify test device. For example: sda + DEVICE: "" + SKIP_INSTALL: "False" + +run: + steps: + - cd ./automated/linux/device-read-perf/ + - ./device-read-perf.sh -d "${DEVICE}" -s "${SKIP_INSTALL}" + - ../../utils/send-to-lava.sh ./output/result.txt |