Skip to content

Instantly share code, notes, and snippets.

@ehoanshelt
Created June 25, 2014 22:02
Show Gist options
  • Save ehoanshelt/916231a405d4753f8363 to your computer and use it in GitHub Desktop.
Save ehoanshelt/916231a405d4753f8363 to your computer and use it in GitHub Desktop.
Run a ttfb command with the option of how many time you want the command to run.
function ttfb {
if [[ -z ${maxcount} ]];
then
maxcount=10
fi
if [[ -n ${domain} ]];
then
echo -e "\n\nTTFB measured "${maxcount}" times with 1s intervals:"
br="++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
echo -e ${br}"\n Testing: ${domain}\n"
for ((c=1; c<=${maxcount}; c++));
do
echo ${c} - $(curl -o /dev/null -w "Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} \n" --silent --output /dev/null ${domain});
sleep 1
done
echo ${br};
else
echo -e "\nUsage: ttfb <domain_name>.\n\n"
return 0
fi
}
domain=${1}
maxcount=${2}
ttfb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment