Linux下磁盘IO读写性能测试脚本

#!/bin/sh

#author:reed
#blog:luweikai.blog.51cto.com
#说明:使用自带的dd命令

file=dd.file
BS_COUNT_8K=(8K 12K)
BS_COUNT_64K=(64K 6K)
BS_COUNT_1M=(1M 1K)
list="8K 64K 1M"
wlog=/tmp/ddwrite.log
rlog=/tmp/ddread.log
#write
Write()
{
        echo "[INFO]WRITE"
        for i in $list;do
                bs=$(eval echo \$\{BS_COUNT_$i\[0\]\})
                count=$(eval echo \$\{BS_COUNT_$i\[1\]\})
                echo "dd if=/dev/zero of=$file conv=fsync oflag=direct bs=$bs count=$count"
                dd if=/dev/zero of=$file conv=fsync oflag=direct bs=$bs count=$count 2>>$wlog
                echo " "
                #echo "sleep 3"
                sleep 3
        done
}
#read
Read()
{
        echo "[INFO]READ"
        for i in $list;do
                bs=$(eval echo \$\{BS_COUNT_$i\[0\]\})
                count=$(eval echo \$\{BS_COUNT_$i\[1\]\})
                echo "dd if=$file of=/dev/null iflag=direct bs=$bs count=$count"
                dd if=$file of=/dev/null iflag=direct bs=$bs count=$count 2>> $rlog
                echo " "
                #echo "sleep 3"
                sleep 3
        done
}
Write|tee -a $wlog
echo "please wait 5 seconds......"
sleep 5
Read|tee -a $rlog


你可能感兴趣的:(linux,性能,dd,磁盘读写)