1.命令行执行方式

如:locust -f example.py --host http://192.168.2.129 -u 2 -r 1 -t 10m --headless

$ locust --helpUsage: locust [OPTIONS] [UserClass ...]Common options:-h, --help            show this help message and exit-f LOCUSTFILE, --locustfile LOCUSTFILEPython module file to import, e.g. '../other.py'.Default: locustfile--config CONFIG       Config file path-H HOST, --host HOST  Host to load test in the following format:http://10.21.32.33-u NUM_USERS, --users NUM_USERSNumber of concurrent Locust users. Primarily usedtogether with --headless. Can be changed during a testby inputs w, W(spawn 1, 10 users) and s, S(stop 1, 10users)-r SPAWN_RATE, --spawn-rate SPAWN_RATEThe rate per second in which users are spawned.Primarily used together with --headless-t RUN_TIME, --run-time RUN_TIMEStop after the specified amount of time, e.g. (300s,20m, 3h, 1h30m, etc.). Only used together with--headless. Defaults to run forever.-l, --list            Show list of possible User classes and exitWeb UI options:--web-host WEB_HOST   Host to bind the web interface to. Defaults to '*'(all interfaces)--web-port WEB_PORT, -P WEB_PORTPort on which to run web host--headless            Disable the web interface, and instead start the loadtest immediately. Requires -u and -t to be specified.--web-auth WEB_AUTH   Turn on Basic Auth for the web interface. Should besupplied in the following format: username:password--tls-cert TLS_CERT   Optional path to TLS certificate to use to serve overHTTPS--tls-key TLS_KEY     Optional path to TLS private key to use to serve overHTTPSMaster options:Options for running a Locust Master node when running Locust distributed. A Master node need Worker nodes that connect to it before it can run load tests.--master              Set locust to run in distributed mode with thisprocess as master--master-bind-host MASTER_BIND_HOSTInterfaces (hostname, ip) that locust master shouldbind to. Only used when running with --master.Defaults to * (all available interfaces).--master-bind-port MASTER_BIND_PORTPort that locust master should bind to. Only used whenrunning with --master. Defaults to 5557.--expect-workers EXPECT_WORKERSHow many workers master should expect to connectbefore starting the test (only when --headless used).Worker options:Options for running a Locust Worker node when running Locust distributed.Only the LOCUSTFILE (-f option) need to be specified when starting a Worker, since other options such as -u, -r, -t are specified on the Master node.--worker              Set locust to run in distributed mode with thisprocess as worker--master-host MASTER_NODE_HOSTHost or IP address of locust master for distributedload testing. Only used when running with --worker.Defaults to 127.0.0.1.--master-port MASTER_NODE_PORTThe port to connect to that is used by the locustmaster for distributed load testing. Only used whenrunning with --worker. Defaults to 5557.Tag options:Locust tasks can be tagged using the @tag decorator. These options let specify which tasks to include or exclude during a test.-T [TAG [TAG ...]], --tags [TAG [TAG ...]]List of tags to include in the test, so only taskswith any matching tags will be executed-E [TAG [TAG ...]], --exclude-tags [TAG [TAG ...]]List of tags to exclude from the test, so only taskswith no matching tags will be executedRequest statistics options:--csv CSV_PREFIX      Store current request stats to files in CSV format.Setting this option will generate three files:[CSV_PREFIX]_stats.csv, [CSV_PREFIX]_stats_history.csvand [CSV_PREFIX]_failures.csv--csv-full-history    Store each stats entry in CSV format to_stats_history.csv file. You must also specify the '--csv' argument to enable this.--print-stats         Print stats in the console--only-summary        Only print the summary stats--reset-stats         Reset statistics once spawning has been completed.Should be set on both master and workers when runningin distributed mode--html HTML_FILE      Store HTML report fileLogging options:--skip-log-setup      Disable Locust's logging setup. Instead, theconfiguration is provided by the Locust test or Pythondefaults.--loglevel LOGLEVEL, -L LOGLEVELChoose between DEBUG/INFO/WARNING/ERROR/CRITICAL.Default is INFO.--logfile LOGFILE     Path to log file. If not set, log will go tostdout/stderrOther options:--show-task-ratio     Print table of the User classes' task execution ratio--show-task-ratio-jsonPrint json data of the User classes' task executionratio--version, -V         Show program's version number and exit--exit-code-on-error EXIT_CODE_ON_ERRORSets the process exit code to use when a test resultcontain any failure or error-s STOP_TIMEOUT, --stop-timeout STOP_TIMEOUTNumber of seconds to wait for a simulated user tocomplete any executing task before exiting. Default isto terminate immediately. This parameter only needs tobe specified for the master process when runningLocust distributed.User classes:UserClass             Optionally specify which User classes that should beused (available User classes can be listed with -l or--list)

2.配置文件方式,将所有运行参数写入配置文件locust.conf

在配置文件所在目录命令行直接运行locust,就会自动执行配置文件,也可以通过--config参数指定配置文件。

配置文件优先级:

~/locust.conf -> ./locust.conf -> (file specified using --conf) -> env vars -> cmd args

Example:

# master.conf in current directory
locustfile = locust_files/my_locust_file.py
headless = true
master = true
expect-workers = 5
host = http://target-system
users = 100
spawn-rate = 10
run-time = 10m

3.webUI方式

命令行执行locust -f .\example_task_queue.py

根据提示打开浏览器,输入地址连接http://localhost:8089

输入测试的用户数,启动用户需要的时间和服务器地址,点击按钮Start swarming,测试就会自动开始执行。

进入主界面可以看到测试实时的统计,点击按钮STOP可以停止测试。

测试结果可以导出。

locust之执行方式相关推荐

  1. Python学习笔记(2)-Python执行方式、变量

    Python执行方式 Python执行过程是由上到下逐行执行,遇到问题即刻终止,现在我们编写多行代码查看效果(Python的一条命令单独占用一行,不允许多条命令写在同一行),如下三图 图1:结果依次打 ...

  2. shell学习之shell执行方式及排错

    shell程序组成: 变量设定: 内置命令: shell的语法结构: 函数及其他命令行的程序所组成 一.shell的执行方式 示例脚本(计算1到100的和): [root@lovelace 51cto ...

  3. iOS 多线程的简单理解(3)执行方式 + 执行对列 的组合

    通过对前面两偏线程理解的总结,自己对线程的理解也逐渐加深,梳理的清晰起来-- 通常在使用线程 的时候,都是要用到 执行对列,执行方式,执行任务, 现在开始新一轮的深入 3. 1. 1  同步 + 串行 ...

  4. 『SHELL』--SHELL脚本执行方式(转)

    Shell脚本的执行方式: 注明:wd代表"脚本保存的目录" 1.fork 语法:/wd/shell.sh fork是最普通的, 就是直接在脚本里面用/wd/shell.sh来调用 ...

  5. linux shell脚本的执行方式与区别

    linux shell脚本的执行方式与区别

  6. 浅析php-fpm静态和动态执行方式的比较

    这篇文章主要介绍了php-fpm静态和动态执行方式的比较,较为详细的分析了php-fpm静态和动态执行方式的原理.参数功能与相关使用技巧,需要的朋友可以参考下 本文实例讲述了php-fpm静态和动态执 ...

  7. mysql 预编译_PHP中MySQL的预处理(预编译)执行方式

    MySQL的预编译是指在创建数据库对象时就将指定的SQL语句编译完成,这时SQL语句已经被MySQL解析.审查,所以相对传统的执行方式(每处理一个SQL语句就要解析SQL语句.检查语法和语义),预编译 ...

  8. oracle某个存过的执行时间,java – 为什么oracle存储过程的执行时间会大大增加,具体取决于它的执行方式?...

    这是我的问题: >我们有一个名为:HEAVY_SP的存储过程,在所有场景中都使用相同的参数 >我们有一个oracle sql开发人员.这可以称为:IDE 根据执行方式,执行时间大大增加: ...

  9. hive脚本执行方式

    2019独角兽企业重金招聘Python工程师标准>>> 1. hive脚本的执行方式 hive脚本的执行方式大致有三种:  1. hive控制台执行:  2. hive -e &qu ...

最新文章

  1. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysq
  2. Gson 使用总结 高级用法
  3. jquery 中后代遍历之children、find区别
  4. PWM信号作用示例——调节台灯亮度
  5. 《开源框架那点事儿33》极限挑战:用一条循环语句正确输出99表!【前两名奖图书一本】...
  6. 这家公司把三星、联想、微软等7家公司给告了 侵犯其触摸屏专利
  7. qt5 linux apt get,Ubuntu 14.04下安装并配置Qt5.7.0
  8. CentOS 6.4用源代码安装LNMP环境
  9. 软件-浏览器-GoogleChrome:Google Chrome
  10. 编译程序与解释程序区别
  11. c语言数据结构课程设计停车场管理系统,数据结构课程设计报告停车场管理系统...
  12. 平安银行广州分行:以金融赋能慈善 释放更大社会效能
  13. 沧海一声笑(最好版)
  14. 12月编程语言排行榜公布啦~
  15. 一文搭建自己博客/文档系统:搭建,自动编译和部署,域名,HTTPS,备案等
  16. Qt的QImage类
  17. 服务器阻止程序运行怎么破,Discuz论坛对服务器的请求已遭到某个扩展程序的阻止问题解决方法...
  18. 虚拟化大拿炮轰Citrix
  19. vue单个表单的校验清空
  20. 现在的网页该不该兼容IE6/7

热门文章

  1. MRS CDL架构设计与实现
  2. Fresco图片加载+EventBus+Butterknife+Retrofit+RxJava+RxAndroid
  3. React高阶组件(HOC)
  4. 仿起点中文网的小说网站——JavaEE大作业
  5. 低频125KHZ|134.2KHZ安卓手持机|RFID智能终端CK-LH100-SYS性能与应用方案
  6. 超硬核,Nacos实现原理详细讲解
  7. 关于联想昭阳k20-80触摸屏关闭
  8. createJs继承
  9. 梯度弥散与梯度爆炸及其解决方法
  10. 金山办公和金山软件是同一家公司?复盘金山办公成长史 | 云计算