Skip to content

Instantly share code, notes, and snippets.

@nimf
Last active March 24, 2023 22:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nimf/d3bace35146164fd6df006d983a05c9f to your computer and use it in GitHub Desktop.
Save nimf/d3bace35146164fd6df006d983a05c9f to your computer and use it in GitHub Desktop.
Measuring HTTP/2 request with CURL
#!/usr/bin/env bash
HELP="Usage: curltime.sh HOSTNAME [SAMPLES_COUNT] [PATH]"
if [ $# -eq 0 ]; then
echo "Please, provide a hostname."
echo $HELP
exit 1
fi
SAMPLES=5
if [ $# -gt 1 ] && [ $2 -gt 0 ]; then
SAMPLES=$2
fi
MEASURED_PATH=generate_204
if [ $# -eq 3 ]; then
MEASURED_PATH=$3
fi
MEASURED_HOST=$1
MEASURED_IP=$(host $MEASURED_HOST | head -n 1 | awk '{print $4}')
echo -e "Measuring HTTP/2 request to https://$MEASURED_HOST/$MEASURED_PATH excluding name resolution.\n"
for ((i=1;i<=SAMPLES;i++))
do
echo "Sample $i/$SAMPLES"
curl --http2 -w "Time connect: %{time_connect}
Time appconnect: %{time_appconnect}
Time pretransfer: %{time_pretransfer}
Time start transfer: %{time_starttransfer}
Total time: %{time_total}\n" \
--resolve $MEASURED_HOST:443:$MEASURED_IP \
-o /dev/null https://$MEASURED_HOST/$MEASURED_PATH
echo ""
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment