I have the following test plan:
I want to have 1 thread on each line of csv file.
How can I achieve it?
I have the following test plan:
I want to have 1 thread on each line of csv file.
How can I achieve it?
这是可能的,但您需要在jmeter 启动之前计算 CSV 文件中的行数,例如:
在 JMeter 中使用__P()函数定义“线程数”,如
${__P(threads,)}
您可以通过命令行参数传递threads
属性值,例如-J
jmeter -Jthreads=60 ....
您可以使用操作系统命令来计算 CSV 文件中的行数,例如:
对于 MS Windows,使用 Xoce 웃 Пepeúpa 建议的“for”循环,例如创建 ieruntest.bat
文件,如:
setlocal EnableDelayedExpansion
set "cmd=findstr /R /N "^^" PATH_TO_YOUR_FILE.CSV | find /C ":""
for /f %%a in ('!cmd!') do set threads=%%a
jmeter.bat -Jthreads=%threads% -n -t test.jmx ...
对于 Linux/Unix,您可以使用wc和awk命令组合并运行 JMeter,如下所示:
./jmeter -Jthreads="$(wc -l PATH_TO_YOUR_FILE.CSV | awk {'print $1'})" -n -t test.jmx
理论上Linux方式也应该适用于OS X。
有关JMeter 属性和使用它们的方式的更多信息, 请参阅Apache JMeter 属性定制指南