Created
August 19, 2018 15:55
-
-
Save fbarrios/7cbe0392a9be73e6505400d316f85949 to your computer and use it in GitHub Desktop.
Small script to test the latency of DigitalOcean servers by downloading a 10MB sample file from each.
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
import urllib.request | |
import time | |
# Small script to test the latency of DigitalOcean servers by downloading | |
# a 10MB sample file from each. | |
REQ_FORMAT = "http://speedtest-{r}.digitalocean.com/10mb.test" | |
ZONES = { | |
'nyc1', 'nyc2', 'nyc3', | |
'ams2', 'ams3', | |
'sfo1', 'sfo2', | |
'sgp1', | |
'lon1', | |
'fra1', | |
'tor1', | |
'blr1' | |
} | |
def main(): | |
times = [] | |
for zone in ZONES: | |
ts = time.time() | |
url = REQ_FORMAT.format(r=zone) | |
urllib.request.urlretrieve(url) | |
tf = time.time() | |
times.append((tf - ts, zone)) | |
for t in sorted(times): | |
print("{t} seg for region {r}".format(t=t[0], r=t[1])) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment