1.安装
pip install locustio
![](https://img.haomeiwen.com/i4179872/0df0281177c5564e.png)
安装成功后,提示:Successfully installed Jinja2-2.9.6 MarkupSafe-1.0 Werkzeug-0.12.2 click-6.7 flask-0.12.2 gevent-1.1.1 greenlet-0.4.12 itsdangerous-0.24 locustio-0.7.5 msgpack-python-0.4.8
2.Installing ZeroMQ
运行Locust分布在多个进程/机器,安装pyzmq:pip install pyzmq
![](https://img.haomeiwen.com/i4179872/34701323e5daebf9.png)
3.quickstart
新建baidu_load.py:
from locust import HttpLocust, TaskSet, task
class UserBehavior(TaskSet):
@task(1)
def baidu(self):
self.client.get("/")
class WebsiteUser(HttpLocust):
"""docstring for WebsiteUser"""
task_set = UserBehavior
min_wait = 5000
max_wait = 9000
4.运行locust
locust -f baidu_load.py --host=http://baidu.com
![](https://img.haomeiwen.com/i4179872/34f9b89f1cee2e8e.png)
5.进入localhost:8089
设置虚拟用户和访问速度:
![](https://img.haomeiwen.com/i4179872/52608dc9b24b5727.png)
![](https://img.haomeiwen.com/i4179872/4440410e4841ad2a.png)
网友评论