Skip to content

Instantly share code, notes, and snippets.

@astrolox
Created July 6, 2020 11:00
Show Gist options
  • Save astrolox/8b16ca6cbf4107c9a6de630a4e140774 to your computer and use it in GitHub Desktop.
Save astrolox/8b16ca6cbf4107c9a6de630a4e140774 to your computer and use it in GitHub Desktop.
Demonstration of naive and incorrect way to compare web performance.
#!/usr/bin/env bash
# This script demonstrates a naive and incorrect way to compare the
# performance of HTTP, HTTPS (HTTP/1.1), and HTTPS (HTTP/2).
# This is incorrect because:
# 1. the HTTP response is just a 302, not a full page.
# 2. each request is just for the initial page html and
# not all of the resources required to render the full page.
# 2. each and every HTTPS request is a completely new
# TCP connection and new TLS session.
for i in {1..100}
do
H1=`curl -w "%{time_total}\n" -o /dev/null -s http://www.cachefly.com/`
HS=`curl -w "%{time_total}\n" --http1.1 -o /dev/null -s https://www.cachefly.com/`
H2=`curl -w "%{time_total}\n" --http2 -o /dev/null -s https://www.cachefly.com/`
echo "${H1},${HS},${H2}"
done
echo ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment