Skip to content

Instantly share code, notes, and snippets.

@fbarrios
Created August 19, 2018 15:55
Show Gist options
  • Save fbarrios/7cbe0392a9be73e6505400d316f85949 to your computer and use it in GitHub Desktop.
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.
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