压力测试工具locust_Redis 压力测试

Locust 是一个轻量化的压力测试工具,可以用来对API做简单的压力测试,并提供界面展示响应时间,平均请求时间等相关信息

安装locust#

具体相关文档可以查看 locust

python3 -m pip install locustio

编写测试用例#

# execute script to finish benchmark test# locust -f benchmark.py --host=http://localhost:8000#from locust import HttpLocust, TaskSet, taskclass UserBehavior(TaskSet):    def on_start(self):        """ on_start is called when a Locust start before any task is scheduled """        print('start benchmark test')    def on_stop(self):        """ on_stop is called when the TaskSet is stopping """        print('end benchmark test')    @task(1)    def profile(self):        self.client.request(method="POST", url="/company/get", headers={"Content-Type": "application/x-www-form-urlencoded"}, data={"code":"300049.SZ"})class WebsiteUser(HttpLocust):    task_set = UserBehavior    min_wait = 5000    max_wait = 9000

测试结果#

在测试脚本目录下执行如下脚本可以启动locust dashboard, 需要指定脚本和测试服务器

f17382fa8d504a8986480cd30220d131.png

平均响应时间

c2d95be025983d11ffede69c548e50dd.png
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值