summaryrefslogtreecommitdiff
path: root/run-benchmark.sh
blob: 6643523ad27b5f5eebf2e93e5d5878d8e55f12db (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/bash

set -o nounset
set -o errexit
set -o errtrace
set -o pipefail

BENCHDIR=$(dirname "$(readlink -f "$0")")

FILESYSTEMS="bcache ext4 ext4-no-journal xfs btrfs"
DEVS="/dev/rssda /dev/sdb /dev/sda5"
BENCHES="					\
    dio-randread				\
    dio-randread-multithreaded			\
    dio-randwrite				\
    dio-randwrite-multithreaded			\
    dio-randwrite-unwritten			\
    dio-randwrite-multithreaded-unwritten	\
    dio-randrw					\
    dio-randrw-multithreaded			\
    dio-append					\
    dio-append-one-cpu				\
    buffered-sync-append"
OUT=""
MNT=/mnt/run-benchmark

while getopts "hd:f:b:m:o:" arg; do
    case $arg in
	h)
	    usage
	    exit 0
	    ;;
	d)
	    DEVS=$OPTARG
	    ;;
	f)
	    FILESYSTEMS=$OPTARG
	    ;;
	b)
	    BENCHES=$OPTARG
	    ;;
	m)
	    MNT=$OPTARG
	    ;;
	o)
	    OUT=$OPTARG
	    ;;
    esac
done
shift $(( OPTIND - 1 ))

if [[ -z $DEVS ]]; then
    echo "Required parameter -d missing: device(s) to test"
    exit 1
fi

if [[ -z $OUT ]]; then
    for i in `seq -w 0 100`; do
	OUT=/root/results/$(date -I)_$i
	[[ ! -e $OUT ]] && break
    done
fi

mkdir $OUT
terse=$OUT/terse
full=$OUT/full

truncate --size 0 $terse
truncate --size 0 $full

echo "Test output in $OUT:"

for dev in $DEVS; do
    devname=$(basename $dev)
    model=$(hdparm -i $dev |tr ',' '\n'|sed -n 's/.*Model=\(.*\)/\1/p')

    echo "Device $devname ($model):" |tee -a $terse

    for bench in $BENCHES; do
	benchname=$(basename $bench)
	echo "    $benchname:" |tee -a $terse

	for fs in $FILESYSTEMS; do
	    out=$OUT/$devname-$benchname-$fs
	    printf "        %-16s" $fs: |tee -a $terse

	    $BENCHDIR/prep-benchmark-fs.sh -d $dev -m $MNT -f $fs >/dev/null 2>&1
	    sleep 30 # quiesce
	    (cd $MNT; "$BENCHDIR/benches/$bench") > $out
	    umount $dev

	    echo "**** Device $devname ($model) filesystem $fs benchmark $benchname:" >> $full
	    cat $out >> $full
	    echo >> $full

	    sed -rne '/iops/ s/ +([[:alpha:]]+) ?:.*iops=([0-9]+).*/\1 \2/ p' $out|
		awk '{printf("%8s %8d iops", $1, $2)} END {printf("\n")}'|
		tee -a $terse
	done
    done
done