from locust import HttpUser, TaskSet, task, between
import os,json
import random
# 定义用户行为
def home_index(self):
url = ""
# model_id = random.randint(0,60)
model_id = random.randint(0,5)
# model_id = 0
user_info = {'url':url, 'model_id':model_id}
r = self.client.get("/faceswap", params=user_info)
# print(type(r.text))
class WebsiteUser(HttpUser):
# host = 'http://0.0.0.0:5000'
host = ''
# task_set = UserTask
tasks = [home_index]
wait_time = between(0, 0)
if __name__ == "__main__":
# os.system('locust -f stress_test.py --headless -u 3 -r 1')
os.system('locust -f stress_test.py --headless -u 10 -r 5')
'''
--headless:指定无 web UI模式
-u:保持多少用户同时在请求
-r:初始时每秒启动虚拟用户数(当用户数量达到-u设定的值以后,会一直保持-u的用户数量)
-t:运行多少时间,单位s(请求没有发送完也要停止)
'''
03-05
2726
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-08
1026
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交