pip install locust
mytest.py
from locust import HttpLocust, TaskSet, task
class WebsiteTasks(TaskSet):
def on_start(self):
pass
@task(1)
def index(self):
self.client.get("/")
@task(2)
def about(self):
self.client.get("/about")
class WebsiteUser(HttpLocust):
task_set = WebsiteTasks
host = "http://www.baidu.com"
min_wait = 100
max_wait = 100
说明:
locust -f mytest.py --no-web -c 10 -t 30s
禁用Web界面,以10线程启动测试,共测试30slocust -f mytest.py
填写线程数,开始测试