jmeter命令行常用参数

-n, –nongui
命令行界面启动jmeter

-t, –testfile {filename}
jmx结尾的测试计划,支持相对路径

-l, –logfile {filename}
日志结果文件

-r, –runremote (non-GUI only)
#non-gui模式下启动remote_hosts配置的所有远程server
-R, –remotestart server1,… (non-GUI only)
#non-gui模式下启动指定的server,此时remote_hosts和-r都无效

-p, –propfile {argument}
属性文件

-q, –addprop {argument}
附加的属性文件

-s, –server
运行JMeter服务器

-J, –jmeterproperty {argument}={value}
JMeter 本地属性
-p, –propfile {argument}
Jmeter本地属性文件,默认-p jmeter.properties

-D, –systemproperty {argument}={value}
JAVA系统属性
-S, –systemPropertyFile {filename}
JAVA系统属性文件

-G, –globalproperty (argument)[=(value)]
发送给server的全局属性,可以把属性及值填入global.properties,之后使用-Gglobal.properties

———————————————————————–
JMeter的测试计划在运行Sampler之前会先加载运行属性(jmeter.properties,system.properties等)文件,而且JMeter还提供了方法可以动态修改属性,在命令行中使用【-J】 来指定JMeter Properties,脚本里面使用__P() 函数来获取命令中指定的属性值

 

 

配置说明:

1、并发数设置为${__P(concurrent_number,1)},循环次数取消勾选Forever,设置为${__P(cycles,1)},其中后面的1是默认值,作用是执行一次来调试脚本,这是__P函数的功能(虽然我一直都是用GUI模式来调试脚本的)

2、执行时长设置为${__P(duration,60)},默认1分钟(60s),如果同时设置了循环次数和执行时长,那么满足其中一个条件脚本就会停止。

查看Jmeter的源码,可知执行次数=-1时即表示Forever。以50并发执行20s的命令行如下:

 命令行:

jmeter -n -t E:/script/jmter_interface/baidu-nonGui.jmx -l E:/report/baidu.jtl -e -o E:/report/report_baidu -Jnum_threads=10  -Jramp_time=2 -Jduration=20 -Jcycles=-1

 

 

 打开生成的测试报告文件,index.html,如下:

 

版权声明:本文为lisa2016原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/lisa2016/p/12525604.html