Skip to content

Instantly share code, notes, and snippets.

@tdlm
Created September 12, 2016 19:29
Show Gist options
  • Save tdlm/79fe55c147e644a9f9f9248cbc6e9648 to your computer and use it in GitHub Desktop.
Save tdlm/79fe55c147e644a9f9f9248cbc6e9648 to your computer and use it in GitHub Desktop.
Command to take average time-to-first-byte for a given URL
#!/usr/local/bin/bash
total=0.000
ttfbs=()
for i in `seq 1 5`
do
ttfb=$(curl -s -o /dev/null -w "%{time_starttransfer}" "$1")
total=$(scale=3;echo "$total+$ttfb" | bc)
done
average=$(scale=3;printf %.2f $(echo "$total/5" | bc -l))
echo "Average TTFB for 5 attempts is: $average"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment