我通过 API 调用测试,
locust -f locustfile.py --host=http://localhost --no-web --hatch-rate=20 --clients=10000
并得到了结果
Name # reqs # fails Avg Min Max | Median req/s
--------------------------------------------------------------------------------------------------------------------------------------------
POST 8000/queries.json 137 0(0.00%) 5 2 23 | 5 11.00
--------------------------------------------------------------------------------------------------------------------------------------------
Total 708 0(0.00%)
我想将此结果写入文件。谁能帮我这个?
下面是python中的代码
@task(1)
def test_topview(self):
post_data_topview = """{ "category": "321", "num": 20, "genderCat" : ["23"] }"""
with self.client.request(method="POST", url="http://192.168.1.107:8001/queries.json", headers= {"Content-Type" : "application/json"}, data = post_data_topview, catch_response = True ) as response:
if not matched(response.content) :
response.failure("No content")
非常感谢。