首页 > 其他 > 详细

Locust简介

时间:2020-12-21 18:23:40      阅读:34      评论:0      收藏:0      [点我收藏+]

一、Locust基于python,可编辑性与伸缩性非常好

  1、特性

    python语言编写、分布式和可扩展的-支持成千上万的用户、基于web UI界面的、可支持任何系统

  2、安装

    $ pip3 install locust

   $ pip3 install -e git://github.com/locustio/locust.git@master#egg=locust

  3、示例

import time
from locust import HttpUser, task, between

class QuickstartUser(HttpUser):
    wait_time = between(1, 2.5)

    @task
    def hello_world(self):
        self.client.get("/hello")
        self.client.get("/world")

    @task(3)
    def view_items(self):
        for item_id in range(10):
            self.client.get(f"/item?id={item_id}", name="/item")
            time.sleep(1)

    def on_start(self):
        self.client.post("/login", json={"username":"foo", "password":"bar"})

 

 

 

 

 

 

 

 

 

 

 

 

  

Locust简介

原文:https://www.cnblogs.com/qtp-1/p/14168134.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!