#exec 2>tf.log
#set -x
#dd.sh 测试次数 每次写多少块
total_sum=0
average=0
total_times=0
min=888888
max=0
LIMIT=$1
target=1
tf_card_path="/home/tf"
`mount -t vfat /dev/mmcblk0p1 `
`mount -t vfat /dev/mmcblk0 $tf_card_path`
`mount -t exfat /dev/mmcblk0p1 $tf_card_path`
`mount -t exfat /dev/mmcblk0 $tf_card_path`
while [ "$target" -le $LIMIT ]
do
dd if=/dev/zero of=$tf_card_path/$target.bin bs=1024K count=$2 2>tf.log
type=`cat tf.log | grep seconds | cut -d , -f 3 | cut -d K -f 2`
if [ -z $type ]
then
`cat tf.log`
`umount $tf_card_path`
exit 1
fi
if [ "$type" == "B/s" ]
then #KB
result=`cat tf.log | grep seconds | cut -d , -f 3 | cut -d K -f 1`
else #MB
result=`cat tf.log | grep seconds | cut -d , -f 3 | cut -d M -f 1`
result=`echo $result | awk '{ printf "%0.2f\n" ,$1*1024}'`
fi
total_sum=`echo $total_sum $result | awk '{ printf "%0.2f\n" ,$1+$2}'`
echo result:$result total_sum:$total_sum
total_times=`expr $total_times + 1`
int_result=`echo $result | cut -d . -f 1`
int_min=`echo $min | cut -d . -f 1`
int_max=`echo $max | cut -d . -f 1`
if [ $int_result -lt $int_min ]
then
min=$result
fi
if [ $int_result -gt $int_max ]
then
max=$result
fi
let "target+=1"
done
`umount $tf_card_path`
average=`echo $total_sum $total_times | awk '{ printf "%0.2f\n" ,$1/$2}'`
echo -e "\033[32m total_times:$total_times \n total_sum:$total_sum\n average:$average KB/s\n max:$max KB/s\n min:$min KB/s \033[0m"
一个测试tf卡性能的脚本
最新推荐文章于 2021-07-22 15:36:08 发布