Skip to content

Instantly share code, notes, and snippets.

@amontalenti
Last active August 29, 2015 13:59
Show Gist options
  • Save amontalenti/10935601 to your computer and use it in GitHub Desktop.
Save amontalenti/10935601 to your computer and use it in GitHub Desktop.
import time
import random
import requests
words = [word.strip() for word in open("/usr/share/dict/words")]
names = ["John", "Bob", "Peter", "Joe", "Sarah", "Clare"]
sections = ["politics", "entertainment", "life", "sports"]
apikeys = ["arstechnica_com", "foxnews_com"]
def measured_query(apikey, q):
start = time.time()
resp = requests.get("http://ue1a-dash-search.cogtree.com:8888/autocomplete/{}?q={}".format(apikey, q))
end = time.time()
return (q, end-start, resp)
while True:
q = " ".join([random.choice(names), random.choice(sections)])
print measured_query(random.choice(apikeys), q)
time.sleep(0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment