zoukankan      html  css  js  c++  java
  • python locust_TaskSet声明任务的典型方法是使用task装饰器的两种方法

    为TaskSet声明任务的典型方法是使用task装饰器。min_waitMAX_WAIT属性也可以在使用taskset类中重写。

    from locust import Locust, TaskSet, task
    class MyTaskSet(TaskSet):
        min_wait = 5000
        max_wait = 15000
        @task(1)
        def my_taskone(self):
            print("executing my_task one")
        @task(3)
        def my_tasktwo(self):
            print("executing my_task tow")
        '''
        使用以下locustfile,每个用户将在任务之间等待5到15秒:
        '''
    class MyLocust(Locust):
        task_set = MyTaskSet
    

      

    使用@task装饰器来声明任务是一种方便,通常是最好的方法。但是,也可以通过设置tasks属性来定义TaskSet的任务 (使用@task装饰器实际上只会填充tasks属性)。

    from locust import Locust, TaskSet, task
    def my_taskone(l):
        print("executing my_task one")
    def my_tasktwo(l):
        print("executing my_task tow")
        '''
        my_task执行的可能性是another_task的 3倍。
        '''
    class MyTaskSet(TaskSet):
        tasks = {my_taskone: 3, my_tasktwo: 1}
        '''
        使用以下locustfile,每个用户将在任务之间等待5到15秒:
        '''
    class MyLocust(Locust):
        task_set = MyTaskSet
        min_wait = 5000
        max_wait = 15000
    

      

  • 相关阅读:
    P1855 榨取kkksc03
    P1359 租用游艇
    P1656 炸铁路
    P1536 村村通
    P3367 【模板】并查集
    P3395 路障(洛谷)
    P1135 奇怪的电梯(洛谷)
    P1331 海战(洛谷)
    conda安装和pip安装的国内镜像配置
    cvpr2020 | 图像增强与恢复论文盘点
  • 原文地址:https://www.cnblogs.com/tallme/p/11185639.html
Copyright © 2011-2022 走看看