Created
March 24, 2016 23:14
-
-
Save andygimma/ef6f6622a517268ae2b0 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
import urllib2 | |
import thread | |
import sys | |
def fetch_api(url): | |
res = urllib2.urlopen(url) | |
def fetch_api_hits(url, number_of_hits): | |
for i in range(number_of_hits): | |
fetch_api(url) | |
print i | |
def fetch_api_concurrent_users(url, number_of_hits, number_of_users): | |
for i in range(number_of_users): | |
thread.start_new_thread(fetch_api_hits, (url, number_of_users,)) | |
if __name__ == '__main__': | |
url = sys.argv[1] | |
number_of_hits = int(sys.argv[2]) | |
number_of_users = int(sys.argv[3]) | |
fetch_api_concurrent_users(url, number_of_hits, number_of_users) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment