Python 负载测试工具 Locust实践
1)安装locust命令行执行pip install locustio2)准备代码task.pyfrom locust import HttpLocust, TaskSet, task
class WebsiteTasks(TaskSet):
def on_start(self):
self.client.post("/login", {
"username": "yourname",
"password": "yourpass"
})
@task
def index(self):
self.client.get("/")
@task
def about(self):
self.client.get("/account/new")
class WebsiteUser(HttpLocust):
task_set = WebsiteTasks
min_wait = 5000
max_wait = 15000
3)开启服务命令行执行locust -f task.py -H http://127.0.0.1:80
4)打开管理界面http://127.0.0.1:8089/并配置,模拟人数 每秒请求数
结果如下
感谢分享
页:
[1]