|
@@ -5,7 +5,9 @@ import json
|
|
|
import requests
|
|
|
import time
|
|
|
|
|
|
-url = "http://47.98.154.124:6060/nlp"
|
|
|
+from concurrent.futures.thread import ThreadPoolExecutor
|
|
|
+
|
|
|
+
|
|
|
|
|
|
list_data = {
|
|
|
"text_list_a": ["凯旋", "毛泽东", "周恩来"],
|
|
@@ -32,11 +34,11 @@ body3 = {
|
|
|
|
|
|
body4 = {
|
|
|
"data": {
|
|
|
- "text_list_a": ["牛逼", "毛泽东", "王一博"],
|
|
|
- "text_list_b": ["肖战", "邓小平", "绝了", "蒋介石"],
|
|
|
- "score_list_b": [100, 1000, 500, 40],
|
|
|
- "symbol": 1,
|
|
|
- },
|
|
|
+ "text_list_a": ["牛逼", "毛泽东", "王一博"],
|
|
|
+ "text_list_b": ["肖战", "邓小平", "绝了", "蒋介石"],
|
|
|
+ "score_list_b": [100, 1000, 500, 40],
|
|
|
+ "symbol": 1,
|
|
|
+ },
|
|
|
"function": "similarities_cross_avg"
|
|
|
}
|
|
|
|
|
@@ -45,10 +47,17 @@ body5 = {
|
|
|
"function": "similarities_cross_mean"
|
|
|
}
|
|
|
|
|
|
-headers = {"Content-Type": "application/json"}
|
|
|
|
|
|
-a = time.time()
|
|
|
-response = requests.post(url=url, headers=headers, json=body1)
|
|
|
-b = time.time()
|
|
|
-print(json.dumps(response.json(), ensure_ascii=False, indent=4))
|
|
|
-print(b - a)
|
|
|
+def test_request(url):
|
|
|
+ headers = {"Content-Type": "application/json"}
|
|
|
+ a = time.time()
|
|
|
+ response = requests.post(url=url, headers=headers, json=body5)
|
|
|
+ b = time.time()
|
|
|
+ print(json.dumps(response.json(), ensure_ascii=False, indent=4))
|
|
|
+ print(b - a)
|
|
|
+
|
|
|
+
|
|
|
+url_list = ["http://47.98.154.124:6060/nlp"] * 10
|
|
|
+
|
|
|
+with ThreadPoolExecutor(max_workers=3) as Pool:
|
|
|
+ Pool.map(test_request, url_list)
|