一个测试tf卡性能的脚本

#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"



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值