测试串行、并发、读、写 4类操作,每类操作又可以指定各种bs及count值,循环压测。每种场景一般执行3次,取平均值。
一、 串行写
#!/bin/sh bs_list=(256k 1024k 10M 20M 50M 100M 1G)cnt_list=(40000 10000 1000 500 200 100 10) for i in {0..6}do for j in {0..2}do logfile=dd_${bs_list[$i]}_cnt${cnt_list[$i]}_${j}.txt echo -e "test ${j} started\n" > $logfileecho -e "started time `date`\n" >> $logfile dd if=/dev/zero of=testfile1 bs=${bs_list[$i]} count=${cnt_list[$i]} oflag=direct,nonblock 2>> $logfile echo -e "\nfinished time `date`" >> $logfileecho -e "\ntest ${j} finished" >> $logfilesleep 5 done sleep 30done
复制
二、 4并发写
#!/bin/sh # ddtest_write_conc.sh bs_list=(256k 1024k 10M 20M 50M 100M 1G)cnt_list=(40000 10000 1000 500 200 100 10) for i in {0..6}do for j in {0..2}do logfile=dd_conc_${bs_list[$i]}_cnt${cnt_list[$i]}_${j}.txt echo -e "test ${j} started\n" > $logfileecho -e "started time `date`\n" >> $logfile for conc in {0..3}do{dd if=/dev/zero of=testfile1 bs=${bs_list[$i]} count=${cnt_list[$i]} oflag=direct,nonblock 2>> $logfile} &done wait echo -e "\nfinished time `date`" >> $logfileecho -e "\ntest ${j} finished" >> $logfilesleep 5 done sleep 30done
复制
三、 串行读
#!/bin/sh # ddtest_read_serial.sh bs_list=(256k 1024k 10M 20M 50M 100M 1G)cnt_list=(40000 10000 1000 500 200 100 10) for i in {0..6}do for j in {0..2}do logfile=dd_${bs_list[$i]}_cnt${cnt_list[$i]}_${j}.txt echo -e "test ${j} started\n" > $logfileecho -e "started time `date`\n" >> $logfile dd if=testfile1 of=/dev/null bs=${bs_list[$i]} count=${cnt_list[$i]} iflag=direct,nonblock 2>> $logfile echo -e "\nfinished time `date`" >> $logfileecho -e "\ntest ${j} finished" >> $logfilesleep 5 done sleep 30done
复制
四、 4并发读
#!/bin/sh bs_list=(256k 1024k 10M 20M 50M 100M 1G)cnt_list=(40000 10000 1000 500 200 100 10) for i in {0..6}do for j in {0..2}do logfile=dd_conc_${bs_list[$i]}_cnt${cnt_list[$i]}_${j}.txt echo -e "test ${j} started\n" > $logfileecho -e "started time `date`\n" >> $logfile for conc in {0..3}do{dd if=testfile1 of=/dev/null bs=${bs_list[$i]} count=${cnt_list[$i]} iflag=direct,nonblock 2>> $logfile} &done wait echo -e "\nfinished time `date`" >> $logfileecho -e "\ntest ${j} finished" >> $logfilesleep 5 done sleep 30done
复制
五、 输出解析
取执行时间
cat dd_* | grep -E 'MB/s|GB/s' | awk '{ print $6 }'
复制
取吞吐量
cat dd_* | grep -E 'MB/s|GB/s' | awk '{ print $8 }'
复制