Skip to content

Instantly share code, notes, and snippets.

@SindreSvendby
Created April 6, 2016 14:05
Show Gist options
  • Save SindreSvendby/aa07f4458df348c64cdd5f52b5e44778 to your computer and use it in GitHub Desktop.
Save SindreSvendby/aa07f4458df348c64cdd5f52b5e44778 to your computer and use it in GitHub Desktop.
# Send in urls as arguments, this
# script will loop over the arguments and do 100 request to each url
# it will report the Average time to first byte for each site.
LOOP=100;
for SITE in "$@"
do
echo "Requesting $SITE $LOOP times ...";
SUM=0;
for i in $(seq 1 $LOOP)
do
TTFB=`curl -o /dev/null -w "%{time_starttransfer}" $SITE 2>/dev/null | sed 's/,/./'`;
echo -e "$i: $TTFB";
SUM=`bc <<< "$SUM + $TTFB"`;
done;
echo "Average TTFB for $SITE after $LOOP number of times is `bc <<< "scale=3;$SUM/$LOOP"`))";
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment