-
-
Save mayurah/1e8a223653ac08659b1c1276e5465459 to your computer and use it in GitHub Desktop.
CURL download benchmark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/ffp/bin/bash | |
# https://linhost.info/2013/10/download-test-files/ | |
SOURCES=( | |
"http://ns0.multikabel.net/100mb.nul" | |
"http://servermars.nl/100mb.bin" | |
"http://speedtest.tweak.nl/100mb.bin" | |
"http://cachefly.cachefly.net/100mb.test" | |
"http://mirror.leaseweb.com/speedtest/100mb.bin" | |
"http://mirror.de.leaseweb.net/speedtest/100mb.bin" | |
"http://178.238.129.83/bigtest.tgz" | |
"http://speedtest.wdc01.softlayer.com/downloads/test100.zip" | |
"http://testmeplease-eu.s3.amazonaws.com/100mb.bin" | |
"http://testmeplease-us.s3.amazonaws.com/100mb.bin" | |
) | |
for (( i = 0 ; i < ${#SOURCES[@]} ; i++ )) do | |
SOURCE=${SOURCES[$i]} | |
DOWNLOAD_RESULT=`curl -o /dev/null ${SOURCE} -w "%{speed_download}|%{size_download}|%{time_total}|%{time_namelookup}|%{time_connect}|%{time_pretransfer}|%{time_redirect}|%{time_starttransfer}|%{num_connects}\n" -s | sed 's/^|//; s/|$//; s/[ ]*|[ ]*/|/g;'` | |
oIFS="$IFS"; IFS=$'\n' | |
for line in $DOWNLOAD_RESULT; do | |
IFS='|' | |
arr=($line) | |
SPEED_mbit=`echo | awk '{ print "'"${arr[0]}"'"*0.000008 }'`; | |
SPEED_kbit=`echo | awk '{ print "'"${arr[0]}"'"*0.008 }'`; | |
COMPUTED_SPEED=`echo | awk '{ print ("'"${arr[1]}"'"/"'"${arr[2]}"'")*0.000008 }'`; | |
SOURCE_NAME=`basename $(dirname "${SOURCE}")` | |
SOURCE_IP=`ping -c 1 ${SOURCE_NAME} | grep -Eo -m 1 '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'` | |
IP_2_COUNTRY=`curl http://api.wipmania.com/${SOURCE_IP}?google.com -s` | |
echo `date +%d-%m-%Y/%H:%M/%Z` ${SOURCE} ${IP_2_COUNTRY} ${SOURCE_IP} $SPEED_mbit"/mbps" $SPEED_kbit"/kbps" ${arr[1]}"/bytes" "avg:"${COMPUTED_SPEED}"/mbit" >> ~/speedtest.txt | |
done | |
IFS="$oIFS" | |
sleep 30 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment