在摘要报告侦听器文件名中使用时间函数
Using time function in Summary Report listener filename
在 JMeter (5.1.1) 中,我有一个摘要报告,我试图将其另存为带时间戳的文件。文件名值如下所示:
D:\Load Tests\example.com\Results${__time(yyyy-MM-dd-HH-mm-ss,)}_summary.csv
但是,而不是使用 __time()
函数的结果创建文件,例如2019-07-22-10-24-03_summary.csv
,它实际上生成了一个名为 ${__time(yyyy-MM-dd-HH-mm-ss,)}_summary.csv
.
的文件名
我尝试创建一个名为 timestamp
的用户定义变量,其值为 ${__time(yyyy-MM-dd-HH-mm-ss,)}
并用 ...${timestamp}_summary.csv
引用它,但这同样会导致 $(timestamp)_summary.csv
。
我看到一个 JMeter Archive post 关于一个与我 2006 年类似的问题,其中暗示侦听器文件名解析得太早,无法使用函数和变量,但我希望 JMeter 能够13年跨过这个坎
是否可以在 JMeter GUI 中为侦听器文件名使用变量并像上面的时间戳一样动态设置它们?
如果没有,是否有使用 Groovy 执行此操作的替代方法?这会在哪里 - 也许在设置线程 JR223 采样器中?我试过这个并且似乎设法以编程方式更改文件名,但没有保存文件。
更新答案:
我只需要将路径定界符从 \
反转为 /
。
D:/Load Tests/example.com/Results/${__time(yyyy-MM-dd-HH-mm-ss,)}/summary.csv
你should not be using any Listeners in your tests as it violates JMeter Best Practices
Use as few Listeners as possible; if using the -l flag as above they can all be deleted or disabled.
你应该running JMeter in non-GUI mode喜欢:
jmeter -n -t test.jmx -l summary.jtl
如果您想修改 summary.jtl
文件名以包含时间戳 - 您可以使用 date and time 命令组合,例如:
jmeter -n -t test.jmx -l %date:~-4%-%date:~4,2%-%date:~7,2%-%time:~0,2%-%time:~3,2%-%time:~6,2%_summary.jtl
演示:
我一般不写长答案,但你触及了一个痛点,
听众是典型的例子不能和你一起生活,不能没有你
JMeter的心态是负载测试(虽然可以用于功能测试)
因此moto/best的做法是You shouldn't use it
Use CLI mode: jmeter -n -t test.jmx -l test.jtl
Use as few Listeners as possible; if using the -l flag as above they can all be deleted or disabled.
Don't use "View Results Tree" or "View Results in Table" listeners during the load test, use them only during scripting phase to debug your scripts.
但是...在同一文档中它建议 testing/debugging
Create a simple Test Plan containing the JSR223 Sampler and Tree View Listener. Code the script in the sampler script pane, and test it by running the test.
Basically/In结束,你需要使用-l myresults.jtl
保存第一个jtl文件
然后使用 JMeterPluginsCMD 将其转换为 CSV,示例:
JMeterPluginsCMD.bat --generate-csv test.csv --input-jtl results.jtl --plugin-type ResponseTimesOverTime
或者以 JMeter 的方式创建 dashboard
jmeter -g <log file> -o <Path to output folder>
我遇到了这个问题,发现当您使用斜杠而不是反斜杠指定路径时它会起作用。
例如:
D:\Load
Tests\example.com\Results${__time(yyyy-MM-dd-HH-mm-ss,)}_summary.csv
无效。但是:
./Load
Tests/example.com/Result/${__time(yyyy-MM-dd-HH-mm-ss,)}_summary.csv
会起作用。
在 JMeter (5.1.1) 中,我有一个摘要报告,我试图将其另存为带时间戳的文件。文件名值如下所示:
D:\Load Tests\example.com\Results${__time(yyyy-MM-dd-HH-mm-ss,)}_summary.csv
但是,而不是使用 __time()
函数的结果创建文件,例如2019-07-22-10-24-03_summary.csv
,它实际上生成了一个名为 ${__time(yyyy-MM-dd-HH-mm-ss,)}_summary.csv
.
我尝试创建一个名为 timestamp
的用户定义变量,其值为 ${__time(yyyy-MM-dd-HH-mm-ss,)}
并用 ...${timestamp}_summary.csv
引用它,但这同样会导致 $(timestamp)_summary.csv
。
我看到一个 JMeter Archive post 关于一个与我 2006 年类似的问题,其中暗示侦听器文件名解析得太早,无法使用函数和变量,但我希望 JMeter 能够13年跨过这个坎
是否可以在 JMeter GUI 中为侦听器文件名使用变量并像上面的时间戳一样动态设置它们?
如果没有,是否有使用 Groovy 执行此操作的替代方法?这会在哪里 - 也许在设置线程 JR223 采样器中?我试过这个并且似乎设法以编程方式更改文件名,但没有保存文件。
更新答案:
我只需要将路径定界符从 \
反转为 /
。
D:/Load Tests/example.com/Results/${__time(yyyy-MM-dd-HH-mm-ss,)}/summary.csv
你should not be using any Listeners in your tests as it violates JMeter Best Practices
Use as few Listeners as possible; if using the -l flag as above they can all be deleted or disabled.
你应该running JMeter in non-GUI mode喜欢:
jmeter -n -t test.jmx -l summary.jtl
如果您想修改 summary.jtl
文件名以包含时间戳 - 您可以使用 date and time 命令组合,例如:
jmeter -n -t test.jmx -l %date:~-4%-%date:~4,2%-%date:~7,2%-%time:~0,2%-%time:~3,2%-%time:~6,2%_summary.jtl
演示:
我一般不写长答案,但你触及了一个痛点,
听众是典型的例子不能和你一起生活,不能没有你
JMeter的心态是负载测试(虽然可以用于功能测试)
因此moto/best的做法是You shouldn't use it
Use CLI mode: jmeter -n -t test.jmx -l test.jtl
Use as few Listeners as possible; if using the -l flag as above they can all be deleted or disabled.
Don't use "View Results Tree" or "View Results in Table" listeners during the load test, use them only during scripting phase to debug your scripts.
但是...在同一文档中它建议 testing/debugging
Create a simple Test Plan containing the JSR223 Sampler and Tree View Listener. Code the script in the sampler script pane, and test it by running the test.
Basically/In结束,你需要使用-l myresults.jtl
然后使用 JMeterPluginsCMD 将其转换为 CSV,示例:
JMeterPluginsCMD.bat --generate-csv test.csv --input-jtl results.jtl --plugin-type ResponseTimesOverTime
或者以 JMeter 的方式创建 dashboard
jmeter -g <log file> -o <Path to output folder>
我遇到了这个问题,发现当您使用斜杠而不是反斜杠指定路径时它会起作用。 例如:
D:\Load Tests\example.com\Results${__time(yyyy-MM-dd-HH-mm-ss,)}_summary.csv
无效。但是:
./Load Tests/example.com/Result/${__time(yyyy-MM-dd-HH-mm-ss,)}_summary.csv
会起作用。