shell计算上传一个文件到CEPH的时间

来源:互联网 发布:老火车头模型淘宝 编辑:程序博客网 时间:2024/06/01 13:11
#!/bin/bashif [ "`dpkg -l | grep " bc " | awk '{print $2}'`" != "bc" ];then        apt-get install bcfiif [ -z $1 ];then        filename="/etc/mime.types"else        filename=$1fiecho "filename is : " $filenamestart_time=`date +%s%N`echo "start time : "`date`filesize=`stat $filename | grep Size | awk '{print $2}'`poolsize=` ceph osd pool get images size | awk '{print $2}'`rados put object11 $filename -p images#end_time=`date +%s`end_time=`date +%s%N`echo "end time : "`date`cost_time=$[$end_time-$start_time]cost_time=$(echo "scale=2;$cost_time/1000000000" | bc)echo "cost time :" $cost_time "s"speed=$(echo "scale=2;$filesize*$poolsize/$cost_time/1024/1024" | bc)echo "average time:" $speed "MB/S"


由于shell的精度问题,文件越小误差越大

原创粉丝点击