Created
March 28, 2013 21:30
-
-
Save feifangit/5266966 to your computer and use it in GitHub Desktop.
flask vs nginx, test code
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
import time | |
import sys | |
import MultipartPostHandler, urllib2, cookielib | |
import threading | |
st = 0 | |
def test(url): | |
# cookies = cookielib.CookieJar() | |
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(), | |
MultipartPostHandler.MultipartPostHandler) | |
f = r"/home/feifan/Desktop/hbase-tool.jar" | |
params = {"newfilename": "abc.mp3", | |
"fileobj" : open(f, "rb") } | |
r = opener.open(url, params) | |
#print r.read() | |
print "done", time.time()-st | |
if __name__ == "__main__": | |
''' | |
python comp.py 200 py | |
python comp.py 300 nginx | |
''' | |
runTimes = int(sys.argv[1]) | |
runType = sys.argv[2] | |
url = "pyupload" if runType == "py" else "upload" | |
st = time.time() | |
for x in xrange(runTimes): | |
t = threading.Thread(target=test, args=("http://10.1.1.47:8666/"+url,)) | |
t.start() | |
print "threads created" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment