Created
May 15, 2012 09:27
-
-
Save mariusrugan/2700352 to your computer and use it in GitHub Desktop.
CURL download benchmark
This file contains 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 | |
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
Outputs to text file:
15-05-2012/08:06/UTC http://cachefly.cachefly.net/100mb.test US 205.234.175.175 46.0933/mbps 46093.3/kbps 104857600/bytes avg:46.0938/mbit