问题:
压力测试时,手工一个个加压效率较低
希望脚本循环执行,每次增加一点压力,生成原始数据报告
测试结束后,人工根据测试报告数据去检测压力情况即可
解决方法:
bat脚本和jmx脚本在同一目录,bat脚本配置好加压策略后,运行即可
set PRO_DIR=%~dp0
set loop=1
set rampUp=0
set durTime=60
::For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
::For /f "tokens=1-2 delims=/:" %%a in ('time /t') do (set mytime=%%a%%b)
for /f "delims=" %%a in ('wmic os get localdatetime /value') do set "%%a"
set time=%localdatetime:~0,14%
cd "D:apache-jmeter-5.1.1-ant-all pluginsapache-jmeter-5.1.1in"
for /l %%i in (10,10,10) do (
jmeter.bat -n -t %PRO_DIR%share.jmx -l %PRO_DIR%%time%_durTime#%durTime%_rampUp#%rampUp%_loop#%loop%_threadNum#%%i.jtl -JthreadNum=%%i -JrampUp=%rampUp% -JdurTime=%durTime% -Jloop=%loop%)
pause
脚本中进程组参数化
外部传参用${__P(threadNum,1)}定义
见下图