Here is a Python script I wrote earlier for rapidly requesting a file from a server and timing each transaction. Can I improve this script?
from time import time from urllib import urlopen # vars url = raw_input("Please enter the URL you want to test: ") for i in range(0,100): start_time = time() pic = urlopen(url) if pic.getcode() == 200: delta_time = time() - start_time print "%d" % (delta_time * 100) else: print "error" print "%d requests made. File size: %d B" % (i, len(pic.read()))
I'm new to Python, though, so I'm not sure if this is the best way to go about it.