-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfio-benchmark.sh
executable file
·69 lines (59 loc) · 1.76 KB
/
fio-benchmark.sh
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
#!/bin/bash
if [ -z $2 ]; then
echo Need a blockdevice to benchmark
exit
fi
rounds=5
mkdir -p mntdir
for img in $(find imgs -type f -name $1\*img); do
[ "${img/squashfs/x}" == $img ] || fs_type="squashfs"
[ "${img/erofs/x}" == $img ] || fs_type="erofs"
[ "${img/ext4/x}" == $img ] || fs_type="ext4"
[ "${img/f2fs/x}" == $img ] || fs_type="f2fs"
echo benchmarking $img with $fs_type
dd if=$img of=$2 bs=1048576 > /dev/null 2>&1
umount mntdir 2>/dev/null || umount -l mntdir 2>/dev/null
[ $fs_type == "erofs" ] && mount -t erofs $2 mntdir
[ $fs_type == "squashfs" ] && mount -t squashfs $2 mntdir
[ $fs_type == "ext4" ] && mount -t ext4 -o ro $2 mntdir
[ $fs_type == "f2fs" ] && mount -t f2fs -o ro $2 mntdir
for i in $(find mntdir -type f); do
echo $i
# seq read
if [ -z $3 -o $3 == 'seq' ]; then
round=0
echo "[seqread]"
while [ $round -lt $rounds ]; do
echo 3 > /proc/sys/vm/drop_caches; sleep 0;
fio -filename=$i -rw=read -bs=4k -name=seqbench | grep READ
echo 3 > /proc/sys/vm/drop_caches
sleep 1
round=$((round+1))
done
fi
# randread
if [ -z $3 -o $3 == 'rand' ]; then
echo "[randread]"
round=0
while [ $round -lt $rounds ]; do
echo 3 > /proc/sys/vm/drop_caches; sleep 0;
fio -filename=$i -rw=randread -bs=4k -name=randbench | grep READ
echo 3 > /proc/sys/vm/drop_caches
sleep 1
round=$((round+1))
done
fi
# randread_9m (< 1/100 size of enwik9, 954MiB)
if [ -z $3 -o $3 == 'rand9m' ]; then
echo "[randread_9m]"
round=0
while [ $round -lt $rounds ]; do
echo 3 > /proc/sys/vm/drop_caches; sleep 0;
fio -filename=$i -rw=randread -bs=4k --io_size=9m -name=rand9mbench | grep READ
echo 3 > /proc/sys/vm/drop_caches
sleep 1
round=$((round+1))
done
fi
done
done