Skip to content

Instantly share code, notes, and snippets.

@jishnu7
Created November 28, 2012 07:44
Show Gist options
  • Save jishnu7/4159707 to your computer and use it in GitHub Desktop.
Save jishnu7/4159707 to your computer and use it in GitHub Desktop.
Speed test shell script
http://cdimage.debian.org/debian-cd/6.0.6/i386/iso-cd/debian-6.0.6-i386-netinst.iso
http://mirror.ufs.ac.za/linuxmint//stable/14/linuxmint-14-cinnamon-dvd-64bit.iso
http://cdimage.debian.org/debian-cd/6.0.6/amd64/iso-dvd/debian-6.0.6-amd64-DVD-1.iso
#!/bin/bash
## Speedtest script
## Copyright (C) 2012 Jishnu Mohan <[email protected]>
## Last revised 28-Nov-2012
##
## Usage: speedtest <input file> <output file>
##
## This script takes list of URLs from input text file and outputs
## speed and time it took to access each file/URL
if [ $1 ]
then
FILENAME=$1
else
echo "Usage: speedtest <input file> <output file>"
exit 0
fi
if [ $2 ]
then
OUTPUT=$2
else
OUTPUT="output"
fi
rm -f $OUTPUT
echo -e "URL\tSize(bytes)\tSpeed(bytes/s)\tTime(s)" >> $OUTPUT
counter=0
findspeed () {
local url=$1
curl -w $url'\t%{size_download}\t%{speed_download}\t%{time_total}\n' -o /dev/null -s $url >> $OUTPUT
counter=`expr $counter + 1`
echo -ne "Number of URLs tested: $counter\r"
}
while read line
do
findspeed $line
done < "$FILENAME"
column -t "$OUTPUT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment