Last active
March 9, 2020 12:19
-
-
Save StoneSwine/b2a0c1c5411a51c9a53724fff0e7845b to your computer and use it in GitHub Desktop.
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 python3 | |
import subprocess, time, os | |
import numpy as np | |
DIR = "out/" | |
if not os.path.exists(DIR): | |
os.makedirs(DIR) | |
""" | |
INSTRUCTIONS: | |
curl is built using theese instructions: | |
https://github.com/curl/curl/blob/master/docs/HTTP3.md#quiche-version | |
""" | |
# HTTP/1.1 HTTP/2 HTTP/3 | |
hv = ["--http1.1", "--http2", "--http3"] | |
# download the same webiste using http{1,2,3} | |
urls = """https://cloudflare-quic.com/ | |
https://www.litespeedtech.com/ | |
https://www.facebook.com/ | |
https://h2o.examp1e.net/ | |
https://quic.westus.cloudapp.azure.com/""".split("\n") # https://bagder.github.io/HTTP3-test/ | |
def time_url(m, u): | |
return float(subprocess.run(['./curl_bin/bin/curl', '-w', '%{time_total}', '-o', '/dev/null', '--user-agent', | |
'Performance research of http3 using CURL', '-s', m, u], | |
stdout=subprocess.PIPE).stdout.decode("utf-8").replace(",", ".")) | |
# HTTP/1.1 HTTP/2 HTTP/3 | |
outputs = [[], [], []] | |
for _ in range(100): | |
for u in urls: | |
ov = 0 | |
for m in hv: | |
print(u, m) | |
outputs[ov].append(time_url(m, u)) | |
ov += 1 | |
# save the data for later statistics | |
np.savetxt(DIR + "statistics.csv", np.transpose(np.asarray(outputs)), fmt='%.10f', delimiter=",", | |
header="HTTP1,HTTP2,HTTP3") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment