Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Stack overflow CDN request test in Python
#!/usr/bin/env python
CDN tester for SO. Designed to make lives easier.
python # for default number of tries, 20
python 100 # for a specific number of tries
Rafe Kettler, public domain.
import sys
import urllib2
from time import time
sites = {'sstatic' : '',
'NetDNA' : '',
'Amazon' : '',
'EdgeCast' : '',
def measure_response_time(url, requests):
total_time = 0
for i in range(requests):
start = time()
elapsed = time() - start
total_time += elapsed
return float(total_time * 1000) / requests
if __name__ == '__main__':
tries = int(sys.argv[1])
except IndexError:
tries = 20
for name, url in sites.items():
average_response = measure_response_time(url, tries)
print "%s: %fms average over %d tries" % (name, average_response, tries)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.