扔坑篇——An open source load testing tool(Locust)

An open source load testing tool.

Define user behaviour with Python code, and swarm your system with millions of simultaneous users

一个开源的负载测试工具。 使用Python代码定义用户行为,并使用数百万并发用户群访问您的系统。

这个自然不是我说的,人家官网超赞的:https://www.locust.io/ 完全就是不需要参考别人

pip install locustio

 自己简单写的例子,主要想下次还可以用


from locust import HttpLocust, TaskSet, task


class LeadsCloud(TaskSet):
    '''继承TaskSet类,用于描述用户行为'''

    # 当模拟用户开始执行TaskSet类时,on_start函数就会被调用。
    def on_start(self):
        self.client.post("http://127.0.0.1:5000/login/login", {
            'type': '0',
            'phone': '15842961234',
            'code': '1111'
        })

    @task()
    def test_print(self):
        print("hello world")

    @task()
    def getShoppingList(self):
        self.client.post("http://127.0.0.1:5000/test/getList")


class WebsiteUser(HttpLocust):
    task_set = LeadsCloud  # 指向一个定义的用户行为类
    host = 'http://127.0.0.1'  # 指定一个访问ip
    min_wait = 3000  # 执行事务之间用户等待时间的下限
    max_wait = 6000  # 执行事务之间用户等待时间的上限


if __name__ == "__main__":
   import os
   os.system("locust -f locust_test.py --host=http://127.0.0.1")

访问地址http://localhost:8089/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ZBY52031

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值