Pārlūkot izejas kodu

test algorithm server by multi_thread

MaochengHu 2 gadi atpakaļ
vecāks
revīzija
2ae4ec34f0
1 mainītis faili ar 15 papildinājumiem un 8 dzēšanām
  1. 15 8
      src_code/test/test_src/multi_thread_test.py

+ 15 - 8
src_code/test/test_src/multi_thread_test.py

@@ -14,21 +14,28 @@ from server_utils.read_properties import get_properties_dict
 import requests
 from multiprocessing import Process
 headers = {"Content-Type": "application/json"}
-properties_dict = get_properties_dict()
-inference_address = properties_dict.get("inference_address")
-
+# properties_dict = get_properties_dict()
+# inference_address = properties_dict.get("inference_address")
+import time
 
+num = 1
+t_time = time.time()
 def single_test(input_source=os.path.join(os.getcwd(), "../test_images/test1.jpg")):
+    global  num
+
     while True:
-        request_url = "{}/predictions/yolov5".format(inference_address)
+        request_url = "http://0.0.0.0:8080/predictions/yolov5"
         image_base64 = path2base64(input_source)
+
         payload = {"data": image_base64,
                    "output_methods": str(["pd_xywh_json"]),
                    "base64_bool": True}
-
+        s_time = time.time()
         req = requests.post(url=request_url, data=payload)
-        print(eval(req.text))
-
+        # print(eval(req.text))
+        num += 1
+        print(f"sub {time.time()-s_time} --- {num}")
+        print(f"total {time.time() - t_time} -- {num}")
 
 
 
@@ -36,7 +43,7 @@ def single_test(input_source=os.path.join(os.getcwd(), "../test_images/test1.jpg
 
 if __name__ == '__main__':
 
-    for i in range(3):
+    for i in range(120):
         t = Process(target=single_test)
         t.start()