Skip to content

Instantly share code, notes, and snippets.

@gms8994
Created May 17, 2011 14:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gms8994/976549 to your computer and use it in GitHub Desktop.
Save gms8994/976549 to your computer and use it in GitHub Desktop.
curl timer fetch stackexchange CDNs
#!/bin/bash
REPEAT=20
TIMER=0
function fetchTimer {
URL=$1
CURRENT_TIME=`curl --compressed -w '%{time_total}' -o /dev/null -s $URL`;
TIMER=`echo "$CURRENT_TIME + $TIMER" | bc`
}
for url in "http://sstatic.net/js/full.js" "http://sstatic.stackexchange.netdna-cdn.com/js/full.js" "http://d1d5ue6vu5b30i.cloudfront.net/js/full.js" "http://wac.43df.edgecastcdn.net/8043DF/sstatic/js/full.js"; do
TIMER=0
for (( i=1; i<=$REPEAT; i++ )); do
fetchTimer $url
done
echo $url
echo "scale=2; (1000 * ${TIMER}) / ${REPEAT}" | bc
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment