python locust 性能测试:嵌套
from locust import TaskSet, task, HttpLocust, TaskSequence, seq_task
import subprocess class WebUser(TaskSet):
@task(5)
def first_task(self):
print('执行5次;') @task(2)
class IosUser(TaskSet):
@task(1)
def second_task(self):
print('1次') @task(2)
def three_task(self):
print('2次')
self.interrupt() @task(2)
class AndroidUser(TaskSequence):
@seq_task(2)
@task(1)
def android_task(self):
print('这是android用户;')
self.interrupt() @seq_task(1)
@task(1)
def ios_task(self):
print('这是ios用户;') class LocustFun(HttpLocust):
host = 'https://passport.cnblogs.com'
task_set = WebUser
max_wait = 6000
min_wait = 3000 if __name__ == '__main__':
subprocess.check_call(
'locust -f G:\Interface_framework_pytest\\tmp\\test2.py --no-web -c 10 -r 1')
self.interrupt()函数用于将执行移交给父TaskSet,需要在嵌套中使用,在Locust类的task_set属性指向的主TaskSet中使用会报错:InterruptTaskSet exception具有中断功能,可以与任务加权一起定义模拟用户离开论坛的可能性;
TaskSequence类,装饰器@seq_task(1),控制任务的执行顺序,参数:number;
python locust 性能测试:嵌套的更多相关文章
- Python Locust性能测试框架实践
[本文出自天外归云的博客园] Locust的介绍 Locust是一个python的性能测试工具,你可以通过写python脚本的方式来对web接口进行负载测试. Locust的安装 首先你要安装pyth ...
- python locust 性能测试:locust安装和一些参数介绍
安装参考 https://www.cnblogs.com/fnng/p/6081798.html <虫师大大的,很详细> ps:python3.7暂不支持locust:python3安装建 ...
- python locust 性能测试:locust 关联---提取返回数据并使用
from locust import HttpLocust, TaskSet, taskimport jsonfrom common import readConfig class UserBehav ...
- python locust 性能测试:HOOKS<钩子方法>
为locust中不同类型的事件,提供的钩子方法: from locust import TaskSet, task, events, Locust from locust.clients import ...
- python locust 性能测试:HttpSession
官网解释:用于在请求之间执行Web请求和保留(会话)cookie的类(以便能够登录和退出网站):记录每个请求,以便locust可以显示统计信息: from locust import TaskSet, ...
- python locust 性能测试:locust参数-保证并发测试数据唯一性,循环取数据
from locust import TaskSet, task, HttpLocustimport queue class UserBehavior(TaskSet): @task def test ...
- python locust 性能测试:locsut参数化-保证并发测试数据唯一性,不循环取数据
from locust import TaskSet, task, HttpLocustimport queue class UserBehavior(TaskSet): @task def test ...
- python locust 性能测试:locust 参数化(list) ---循环取数据,数据可重复使用
from locust import TaskSet, task, HttpLocust class UserBehavior(TaskSet): def on_start(self): # 当模拟用 ...
- Python locust性能测试框架模板
locust框架模板 from locust import HttpLocust, TaskSet, task import Queue class UserBehavior(TaskSet): de ...
随机推荐
- [LeetCode] Soup Servings 供应汤
There are two types of soup: type A and type B. Initially we have N ml of each type of soup. There a ...
- [LeetCode] Search in a Binary Search Tree 二叉搜索树中搜索
Given the root node of a binary search tree (BST) and a value. You need to find the node in the BST ...
- Differenciate or distinguish between outlook attachment and embedded image/signature using property accessor in C#.NET
These days, outlook emails are composed in three formats; plain text, html and rtf (rich text format ...
- SET || BZOJ 1588: [HNOI2002]营业额统计 || Luogu P2234 [HNOI2002]营业额统计
题面:P2234 [HNOI2002]营业额统计 题解:随便写写 注意:cmath中abs函数返回的是一个浮点数,在bzoj上会ce 代码: #include<cstdio> #inclu ...
- F#周报2019年第9期
新闻 对于F#,Visual Studio 2019 RC有哪些更新 Visual Studio 2019 RC现在已经发布 C#版本与工具的升级 如何移植桌面应用程序到.NET Core 3.0 对 ...
- yield关键字
1.yield语句有两种形式 (1)yield return <expression>;一次返回一个元素 运行yield return 语句时,会返回一个 值,并记录当前位置及保留该值.下 ...
- Express全系列教程之(五):Express的中间件
一.中间件 从字面意思,我们可以了解到它大概就是做中间代理操作,事实也是如此:大多数情况下,中间件就是在做接收到请求和发送响应中间的一系列操作.事实上,express是一个路由和中间件的web框架,E ...
- JQuery实现一个轮播图
1.HTML <div class="banner"> <div class="b_main"> <div class=" ...
- 如何查看正在执行sql的语句及其父语句调用?如何查看正在执行SQL的具体参数值与执行计划?
---SQL Server查询正在执行的SQL语句及执行计划 select ds.session_id,dr.start_time,db_name(dr.database_id),dr.blockin ...
- Tea for Mac(mac笔记软件)中文版
为大家分享一款好用且免费的mac笔记软件,Tea for Mac提供了实时渲染的Markdown,功能全面,支持各种快捷键,使用tea mac版时,在段首打@即可快速插入图片.标题.列表等元素,非常便 ...