Ser*_*roz 3 python performance-testing locust taurus
我有 locustio 文档中的下一个代码:
from locust import HttpLocust, TaskSet, between
def login(l):
l.client.post("/login", {"username":"ellen_key", "password":"education"})
def logout(l):
l.client.post("/logout", {"username":"ellen_key", "password":"education"})
def index(l):
l.client.get("/")
def profile(l):
l.client.get("/profile")
class UserBehavior(TaskSet):
tasks = {index: 2, profile: 1}
def on_start(self):
login(self)
def on_stop(self):
logout(self)
class WebsiteUser(HttpLocust):
task_set = UserBehavior
wait_time = between(5.0, 9.0)
Run Code Online (Sandbox Code Playgroud)
在蝗虫日志和蝗虫网络(localhost:8089)中我看到了接下来的任务
- /login
- /logout
- /
- /profile
Run Code Online (Sandbox Code Playgroud)
但是,如果我需要在一项任务中包含很少的请求并从完整的任务(而不是 1 个请求)中获取度量,该怎么办?
我想看到的是:
- login
- logout
- index
- profile
Run Code Online (Sandbox Code Playgroud)
我想查看任务名称而不是请求 url。在 Jmeter 中,我可以在一个操作中插入几个请求并获取操作时间(而不是请求)。
您可以为每个请求按属性设置名称name,请参阅示例:
def index(l):
l.client.get("/", name="index")
def profile(l):
l.client.get("/profile", name="my-profile")
Run Code Online (Sandbox Code Playgroud)