Last active
July 15, 2025 09:36
-
-
Save NiceRath/8ccbe11652a3f466fba9e6935dd03500 to your computer and use it in GitHub Desktop.
HTTP2 vs HTTP3 Speedtest Script (to CSV)
This file contains hidden or 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
| set -eo pipefail | |
| if [[ -z "$2" ]] | |
| then | |
| echo 'USAGE:' | |
| echo ' 1 > Domain to target (without www)' | |
| echo ' 2 > Number of requests' | |
| echo '' | |
| echo 'OPTIONAL ENV-VARS:' | |
| echo ' CURL_INT > Interface to use' | |
| exit 1 | |
| fi | |
| if [[ -n "$CURL_INT" ]] | |
| then | |
| CURL_INT="--interface ${CURL_INT}" | |
| else | |
| CURL_INT='' | |
| fi | |
| set -u | |
| DOMAIN="www.$1" | |
| COUNT="$2" | |
| UA='User-Agent: Speedtest' | |
| TIME="$(date +'%s')" | |
| LOG_FILE_H2="/tmp/speedtest_h2_${TIME}.csv" | |
| LOG_FILE_H3="/tmp/speedtest_h3_${TIME}.csv" | |
| COLUMNS='time_connect,time_appconnect,time_total' | |
| echo "$COLUMNS" > "$LOG_FILE_H2" | |
| echo "$COLUMNS" > "$LOG_FILE_H3" | |
| CURL_BIN="curl" | |
| if [ -f ./curl ] | |
| then | |
| CURL_BIN='./curl' | |
| fi | |
| if ! "$CURL_BIN" -H "${UA}" $CURL_INT --http3 -o /dev/null https://google.at 2>/dev/null | |
| then | |
| echo 'DOWNLOAD CURL WITH HTTP3 SUPPORT: https://github.com/stunnel/static-curl/releases' | |
| exit 1 | |
| fi | |
| for i in $(seq "$COUNT") | |
| do | |
| echo "$i" | |
| "$CURL_BIN" -H "${UA}" $CURL_INT --http2 -o /dev/null -w '%{time_connect},%{time_appconnect},%{time_total}\n' "https://${DOMAIN}" 2>/dev/null >> "$LOG_FILE_H2" | |
| sleep 1 | |
| "$CURL_BIN" -H "${UA}" $CURL_INT --http3 -o /dev/null -w '%{time_connect},%{time_appconnect},%{time_total}\n' "https://${DOMAIN}" 2>/dev/null >> "$LOG_FILE_H3" | |
| sleep 1 | |
| done | |
| echo "LOG HTTP/2: $LOG_FILE_H2" | |
| echo "LOG HTTP/3: $LOG_FILE_H3" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment