-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.py
More file actions
32 lines (22 loc) · 747 Bytes
/
Copy pathclient.py
File metadata and controls
32 lines (22 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import time
import sys
import threading
import numpy as np
import requests
num_threads = 100
def send_request(host, port, data):
res = requests.post("http://{}:{}/predict".format(host, port), json=data)
return res.json()
if __name__ == "__main__":
host = sys.argv[1]
port = int(sys.argv[2])
data = {"input": np.random.rand(1, 300).tolist()}
start_time = time.time()
threads = []
for i in range(num_threads):
t = threading.Thread(target=send_request, args=(host, port ,data))
t.start()
threads.append(t)
for t in threads:
t.join()
print("{:.6f}s for processing {} requests.".format(time.time() - start_time, num_threads))