一、編寫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