该软件jmeter是Apache官方开源压力测试软件. jmeter官网:http://jmeter.apache.org/ . 本文使用的版本是 3.0版本, 它需要jdk7及以上版本支持.
网盘下载 : 链接:http://pan.baidu.com/s/1i5lDeDJ 密码:4qes
安装: 参考 http://www.cnblogs.com/benpao1314/p/5953565.html
1, 下载后无需安装,解压后即可使用;
2,配置环境变量
新增 JMETER_HOME = “D:\develop\apache-jmeter-3.0”
CLASSPATH变量,加上%JMETER_HOME%\lib\ext\ApacheJMeter_core.jar;%JMETER_HOME%\lib\jorphan.jar;%JMETER_HOME%\lib\logkit-2.0.jar;
3. 操作完上面的步骤,我们就可以点击Jmeter中bin目录下面的jmeter.bat文件即可打开Jmeter了。
(注意:打开的时候会有两个窗口,Jmeter的命令窗口和Jmeter的图形操作界面,不可以关闭命令窗口)
使用:参考 http://blog.csdn.net/liuxiao723846/article/details/52670046
1、添加线程组:
测试计划 -> 添加 -> Threads(User) -> 线程组
线程数:表示将模拟多少个用户进行测试。
Ramp-Up Period(in seconds):线程启动间隔,所有线程将在这个时间内依次启动。
循环次数:所有线程执行一次为一次循环。
如果线程数为200 ,循环次数为10 ,那么每个线程发送10次请求。总请求数为200*10=2000 。如果勾选了“永远”,那么所有线程会一直发送请求,直到选择停止运行脚本。
2、添加采样器:
采样器可理解为针对前面创建的线程需要做什么事情,这里以添加HTTP请求为例。
线程组 -> 添加 -> Sampler -> TCP请求
3、添加监视器
监视器可以理解为针对结果的不同查看方式。JMeter里提供了多种结果表现形式。
问题1, 中文显示乱码, 在jmeter/bin/jmeter.properties
jsyntaxtextarea.font.family=宋体
sampleresult.default.encoding=UTF-8
问题2,jmeter java.lang.OutOfMemoryError: Java heap space
changed HEAP settings in jmeter.bat from
-Xms512m -Xmx512m
to
-Xms2048m -Xmx2048m
同时由于我的线程特别多几万个,故我把配置里面的 线程组 复选框 Delay Thread creation until needed 勾上了.
最终的配置例子
=========================================================================================
简单的压力测试情况(几分钟的效果):
1.身份验证
00493{"head":{"BisUid":"AAAS0000293171016200305008192","TransCode":"2201","MsgType":"0200","ExSerial":"008192","Acctoper":"8001","TradeType":"2222","BranchNo":"82801","Channel":"vcm","TermNo":"S0000293","TermIp":"192.168.1.72","TransDate":"20171016","TransTime":"200305","TermNoInn":"S0000293","TopBranchNo":"82","BatchNo":"","Token":"","AreaCode":"","EncodeType":"2"},"body":{"OpsitBrhNo":"313675090019","BusinessType":"01","OpsitTellerNo":"355","IdCode":"610528198811203033","CustName":"杨伟"}}
2.客户信息查询
00589{"head":{"BisUid":"AAAS0000293171016200307008193","TransCode":"2525","MsgType":"0200","ExSerial":"008193","Acctoper":"8001","TradeType":"2222","BranchNo":"82801","Channel":"vcm","TermNo":"S0000293","TermIp":"192.168.1.72","TransDate":"20171016","TransTime":"200307","TermNoInn":"S0000293","TopBranchNo":"82","BatchNo":"","Token":"","AreaCode":"","EncodeType":"2"},"body":{"OperFlag":"3","IdType":"0","IdCode":"610528198811203033","AcctNo":"","CustName":"杨伟","IdIssuUnit":"","Sex":"男","OfficPhone":"","HomePhone":"","Mobile":"","ContactAddr":"","PostId":"","Email":"","WorkUnits":""}}