update buildroot - work in progress development
[cmdllinux.git] / buildroot / _pkg / _wget / _wget_speed.0.sh
blobdc8e791a526fc6f6270faf3ee590777d41f831f7
2 [ -z "$1" ] && exit 1
3 URL="$1"
4 echo -ne "$URL "
6 time1=`date +%s.%N`
7 time1_sec=${time1%.*}
8 time1_nanosec=${time1#*.}
10 timeout 10 wget -q -o /dev/null -O - $URL > /tmp/file 2> /dev/null
12 time2=`date +%s.%N`
13 time2_sec=${time2%.*}
14 time2_nanosec=${time2#*.}
17 sec=$((time2_sec - time1_sec))
19 time1_hund=`echo $time1_nanosec | head -c 2 | sed 's/^0\+//'`
20 time2_hund=`echo $time2_nanosec | head -c 2 | sed 's/^0\+//'`
22 [ -z "$time1_hund" ] && time1_hund=0
23 [ -z "$time2_hund" ] && time2_hund=0
25 hund1=$((100 - $time1_hund))
26 hund2=$time2_hund
28 if [ "$((hund1 + hund2))" -ge 100 ]; then
29 sec=$((sec + 1))
30 hund=$((hund1 + hund2 - 100))
31 else
32 hund=$((hund1 + hund2))
35 [ `echo -n "$hund" | wc -c` = 1 ] && \
36 time="${sec}0${hund}" || time="${sec}${hund}"
38 #[ `echo -n "$hund" | wc -c` = 1 ] && \
39 # time="${sec}.0${hund}" || time="${sec}.${hund}"
41 speed=$(($(stat -c %s /tmp/file) * 100 / $time))
42 echo $speed
44 #date +%s%N