Skip to content

Instantly share code, notes, and snippets.

@kil9
Created March 29, 2017 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kil9/b76addae8101ed5ee016c02c7a05e2a6 to your computer and use it in GitHub Desktop.
Save kil9/b76addae8101ed5ee016c02c7a05e2a6 to your computer and use it in GitHub Desktop.
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