password
查看人数
type
status
date
slug
summary
category
icon
tags
作者
状态

基础用法

notion image
文件名称为locustfile.py
启动:locust 命令就行了
notion image
notion image
无GUI运行
命令:locust -f locustfile.py –host=111111 –headless -u 10 -r 2 -t 15s

分布式运行

同一台电脑:

主机: locust -f test3.py –master
从: locust -f test3.py –worker

不同机器

  • 启动主进程:locust -f test.py –master
  • 启动助攻进程:locust -f test.py –worker –master-host=主控机器ip –master-port=5557(默认的端口,如果主控没有修改的话,可以不用写)
 

前置、后置处理

  • on_start :每个虚拟用户在启动时都会调用该方法
  • on_stop 当虚拟用户用户停止运行(被终止)时调用

设置集合点

 

执行权重

Locust会根据你在用户类中定义的任务及其权重随机地模拟用户行为
设置@task(2)参数,test2任务被选择的概率为其他任务的两倍
Python 协程发起请求和运行tampermonkey 脚本编写
Loading...