Commit 0c8dc23f by tinywell

Refactor test_agent.py to enhance test structure and add performance measurement…

Refactor test_agent.py to enhance test structure and add performance measurement for queries. Introduced test_case_1 for timing query responses and organized questions within a dedicated test function.
parent ab665107
import requests import requests
questions = [ import time
"贵阳市各县区设备在线率是多少", def test_all_case():
"贵阳市各个县区 2024 年 11 月 2 日设备在线率是多少", questions = [
"各省实时设备在线率排名", "贵阳市各县区设备在线率是多少",
"各省实时设备在线率排名中,前 5名是哪些省", "贵阳市各个县区 2024 年 11 月 2 日设备在线率是多少",
"各省实时设备在线率排名中,最后 5 名是哪些省", "各省实时设备在线率排名",
"各厂商设备在线率排名中,排名前 10的厂商", "各省实时设备在线率排名中,前 5名是哪些省",
"在厂商设备在线率排名中,上海华测设备在线率排名是多少", "各省实时设备在线率排名中,最后 5 名是哪些省",
"贵阳市的雨量传感器数量有多少 ", "各厂商设备在线率排名中,排名前 10的厂商",
"贵阳市的监测点数量是多少", "在厂商设备在线率排名中,上海华测设备在线率排名是多少",
"贵阳市有三维模型的监测点数量是多少", "贵阳市的雨量传感器数量有多少 ",
"今年 ,贵阳市每月的设备在线率是多少?(注:如果需要按“每月”维度展示,问题中需添加 “每月” 字段,增加问题区分度)", "贵阳市的监测点数量是多少",
"2024 年 贵阳市每月的滑坡仪在线率是多少", "贵阳市有三维模型的监测点数量是多少",
"贵阳市威胁人数在 200 人以上的滑坡监测点数量有多少", "今年 ,贵阳市每月的设备在线率是多少?(注:如果需要按“每月”维度展示,问题中需添加 “每月” 字段,增加问题区分度)",
"2024 年 5 月 20 日到 2024 年 11 月 27 日,贵阳市黄色预警消息占比是多少;", "2024 年 贵阳市每月的滑坡仪在线率是多少",
"2024 年 10 月 1日到 2024 年 10 月31日,贵阳市处置率是多少", "贵阳市威胁人数在 200 人以上的滑坡监测点数量有多少",
"2024 年5 月到 2024 年11 月,贵阳市每月处置率是多少", "2024 年 5 月 20 日到 2024 年 11 月 27 日,贵阳市黄色预警消息占比是多少;",
"2023 年,贵阳市每月处置率是多少", "2024 年 10 月 1日到 2024 年 10 月31日,贵阳市处置率是多少",
"贵阳市预警等级为红色的滑坡监测点数量有多少" "2024 年5 月到 2024 年11 月,贵阳市每月处置率是多少",
] "2023 年,贵阳市每月处置率是多少",
"贵阳市预警等级为红色的滑坡监测点数量有多少"
]
url = "http://localhost:8088/api/agent/rate" url = "http://localhost:8088/api/agent/rate"
for question in questions: for question in questions:
print(question) print(question)
http_response = requests.post(url, json={"query": question}) http_response = requests.post(url, json={"query": question})
print(http_response.json()) print(http_response.json())
print("--------------------------------"*5) print("--------------------------------"*5)
\ No newline at end of file
def test_case_1():
question = "贵阳市各县区设备在线率是多少"
url = "http://localhost:8088/api/agent/rate"
for i in range(10):
start_time = time.time()
http_response = requests.post(url, json={"query": question})
end_time = time.time()
print(f"第 {i+1:02d} 次测试结果 【{question}】 耗时: {end_time - start_time:.2f}秒")
if __name__ == "__main__":
test_case_1()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment