一、编写run_jmeter,bat
@echo off
::设置参数
::参考命令:jmeter -n -t d:\123.jmx -l result.jtl -e -o d:\report\report_1
for /f "tokens=2 delims==" %%a in (\'wmic OS Get localdatetime /value\') do set "dt=%%a"
SET timeStamp=%dt:~0,4%-%dt:~4,2%-%dt:~6,2%_%dt:~8,2%-%dt:~10,2%-%dt:~12,2%
SET jme_bin=E:\project\apache-jmeter-5.1.1\bin
SET LogFile=\result.jtl
set pan=e:
::运行命令行,执行jmeter脚本,把脚本拖到bat上执行即可
::1.进入jmetr的bin目录
::设置bin目录,如果是D盘需要修改下
cd %jme_bin%
%pan%
::2.需要删除LogFile文件,不然下次会报错
del %jme_bin%%LogFile%
::4.执行命令
::报告目录 E:/report
jmeter -n -t %1 -l result.jtl -e -o E:/report/report_%timeStamp%
::4.需要删除LogFile文件,不然下次会报错
::del E:\project\apache-jmeter-5.1.1\bin\result.jtl
del %jme_bin%%LogFile%
pause
执行时,将jmeter脚本文件拖到bat文件上即可。
查看报告文件
二、jmeter 配置文件设置,报告图形参数
在jmeter.properties或者user.properties确认如下配置项:
jmeter.save.saveservice.data_type=true
jmeter.save.saveservice.label=true
jmeter.save.saveservice.response_code=true
# response_data is not currently supported for CSV output
jmeter.save.saveservice.response_data=true
# Save ResponseData for failed samples
jmeter.save.saveservice.response_data.on_error=false
jmeter.save.saveservice.response_message=true
jmeter.save.saveservice.successful=true
jmeter.save.saveservice.thread_name=true
jmeter.save.saveservice.time=true
jmeter.save.saveservice.subresults=true
jmeter.save.saveservice.assertions=true
jmeter.save.saveservice.latency=true
jmeter.save.saveservice.connect_time=true
jmeter.save.saveservice.samplerData=true
jmeter.save.saveservice.responseHeaders=true
jmeter.save.saveservice.requestHeaders=true
jmeter.save.saveservice.encoding=false
jmeter.save.saveservice.bytes=true
jmeter.save.saveservice.url=true
jmeter.save.saveservice.filename=true
jmeter.save.saveservice.hostname=true
jmeter.save.saveservice.thread_counts=true
jmeter.save.saveservice.sample_count=true
jmeter.save.saveservice.idle_time=true
# Timestamp format - this only affects CSV output files
# legitimate values: none, ms, or a format suitable for SimpleDateFormat
jmeter.save.saveservice.timestamp_format=ms
jmeter.save.saveservice.timestamp_format=yyyy/MM/dd HH:mm:ss.SSS