Created
March 29, 2017 12:09
-
-
Save kil9/b76addae8101ed5ee016c02c7a05e2a6 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
import random | |
import requests | |
import time | |
#url = 'http://tgpu102.imgr.nhnsystem.com:30001/darknet1.search?worker_id=1' | |
url = 'http://tgpu102.imgr.nhnsystem.com:41901' | |
IMAGE = 'dog{}.jpg' | |
N = 500 | |
s = time.time() | |
response_times = [] | |
for i in range(N): | |
filename = 'img/' + IMAGE.format(random.randint(1, 5)) | |
with open(filename, 'rb') as f: | |
r_start = time.time() | |
r = requests.post(url, files={'image': f}) | |
r_duration = time.time() - r_start | |
response_times.append(r_duration) | |
if not r.ok: | |
print(i, r) | |
d = time.time()-s | |
print() | |
print('url: {}'.format(url)) | |
print('-'*30) | |
print('{} seconds'.format(d)) | |
print('{} qps'.format(N/d)) | |
print('response time(avg): {} ms'.format(sum(response_times)/len(response_times)*1000)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment