Created
February 24, 2018 17:50
-
-
Save 0xmilan/8ce01d148e9cde95692057701f5b58e8 to your computer and use it in GitHub Desktop.
Check download time for HEAD and GET requests for the linuxmint/mintinstall reviews list.
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/python3 | |
import urllib.request | |
import time | |
import os | |
url = "https://community.linuxmint.com/data/new-reviews.list" | |
CACHE_DIR = os.path.expanduser("~/") | |
reviews_path_tmp = os.path.join(CACHE_DIR, "reviews.list.tmp") | |
start_time = time.time() | |
length_HEAD = urllib.request.urlopen(url).info()['content-length'] | |
elapsed_time = time.time() - start_time | |
print('Content-length: ' + length_HEAD) | |
print('HEAD request time : ' + str(elapsed_time)) | |
start_time = time.time() | |
urllib.request.urlretrieve(url, reviews_path_tmp) | |
length_GET = os.path.getsize(reviews_path_tmp) | |
elapsed_time = time.time() - start_time | |
print('Reviews file size: ' + str(length_GET)) | |
print('GET request time: ' + str(elapsed_time)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment