2019独角兽企业重金招聘Python工程师标准>>>
参考:
http://www.oschina.net/p/locust
http://qiita.com/CkReal/items/cb53518f2d504950c09c
---------------------------------------
1)安装locust
命令行执行
pip install locustio
2)准备代码
task.py
from locust import HttpLocust, TaskSet, taskclass WebsiteTasks(TaskSet):def on_start(self):self.client.post("/login", {"username": "yourname","password": "yourpass"})@taskdef index(self):self.client.get("/")@taskdef about(self):self.client.get("/account/new")class WebsiteUser(HttpLocust):task_set = WebsiteTasksmin_wait = 5000max_wait = 15000
3)开启服务
命令行执行
locust -f task.py -H http://127.0.0.1:80
4)打开管理界面
http://127.0.0.1:8089/
并配置,模拟人数 每秒请求数
结果如下