码迷,mamicode.com
首页 > 其他好文 > 详细

jmeter no-gui模式动态传递场景参数

时间:2017-06-26 21:11:01      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:运行   场景   单位   idt   form   分享   ash   ges   date   

jmeter进行性能压测时,有时候需要在linux上no-gui模式下运行,为了在no-gui模式下更方便的设置脚本的运行的场景,

将脚本的线程数,运行时间设置为动态参数,可以在脚本运行时动态设置“线程数”和“场景运行时间”;详情如下:

#!/bin/bash

## JthreadCount:定义运行的线程数,在脚本中引用“${__P(threadCount,)}”
## JDurationTime:定义场景的运行时间(单位秒S),在脚本中引用“${__P(DurationTime,)}”
## --h:使用方法demo
## --r:运行脚本同时输出报告和日志文件
## --n:运行脚本不输出报告和日志文件


if [ $1 == "--h" ]; then
    ##使用的demo
    echo "./runTest.sh 运行指令(--r) JthreadCount(线程数) JDurationTime(场景运行时间) ScriptName(脚本)"
elif [ $1 == "--r" ]; then
    ##运行脚本,输出报告和日志文件
    ./jmeter.sh -n -JthreadCount=$2 -JDurationTime=$3 -t $4 -j $PWD/result/$(date +%y%m%d%H%M%S)_test_log.log -l $PWD/result/$(date +%y%m%d%H%M%S)_test_result.jtl
elif [ $1 == "--n" ]; then
    #运行脚本不输出报告和日志文件
    ./jmeter.sh -n -JthreadCount=$2 -JDurationTime=$3 -t $4
fi

使用demo:

#在jmeter的bin目录下执行:
./runTest.sh --n 2 30 performanceScript/testScript/demo.jmx

# 2 :线程数
# 30 :场景运行时间
# demo.jmx :要运行的脚本

在脚本中的设置:

技术分享

 

jmeter no-gui模式动态传递场景参数

标签:运行   场景   单位   idt   form   分享   ash   ges   date   

原文地址:http://www.cnblogs.com/veitch-623/p/7082214.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!