压力测试工具locust

作者:iohannes 发布时间: 2025-03-14 阅读量:7

安装

pip3 install locust

编写测试文件

# locustfile.py
from locust import HttpUser, task

class HelloWorldUser(HttpUser):
    @task
    def hello_world(self):
        self.client.get("/code/sh")

启动测试服务

python3 -m locust

配置和运行

浏览器打开: http://localhost:8089/

配置完, 点击运行, 最后达到压力测试结果

更多参考

https://docs.locust.io/en/stable/quickstart.html