测开之路七十二:性能测试工具之locust简介

 

locust官网:https://locust.io/

 

locust安装(不支持python3.7):pip install locustio   或者pycharm安装

官网给出的样例

根据官网代码新建一个脚本

from locust import HttpLocust, TaskSet, task


class WebsiteTasks(TaskSet):

@task(weight=2) # weight:发压的比例,可以不设置
def index(self):
self.client.get("/guonei") # 百度新闻的国内:http://news.baidu.com/guonei

@task(weight=8)
def about(self):
self.client.get("/guoji") # 百度新闻的国际:http://news.baidu.com/guoji


class WebsiteUser(HttpLocust):
task_set = WebsiteTasks
min_wait = 1000 # 最小等待时间,毫秒
max_wait = 3000 # 最大等待时间,毫秒

 

执行:locust -f 脚本 --host=要压的host:locust -f locustfile.py --host=http://news.baidu.com

访问localhost:8089(不能用127.0.0.1)

Statistics页面:

Charts页面

Failures

Exceptions

Download Data

Ctrl + C结束也会在窗口生成数据

 

转载于:https://www.cnblogs.com/zhongyehai/p/11261251.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值