Last active
March 24, 2023 22:22
-
-
Save nimf/d3bace35146164fd6df006d983a05c9f to your computer and use it in GitHub Desktop.
Measuring HTTP/2 request with CURL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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