該軟件jmeter是Apache官方開源壓力測試軟件. jmeter官網:http://jmeter.apache.org/ . 本文使用的版本是 3.0版本, 它須要jdk7及以上版本支持.html
網盤下載 : 連接:http://pan.baidu.com/s/1i5lDeDJ 密碼:4qesjava
安裝: 參考 http://www.cnblogs.com/benpao1314/p/5953565.html apache
1, 下載後無需安裝,解壓後便可使用;測試
2,配置環境變量spa
新增 JMETER_HOME = 「D:\develop\apache-jmeter-3.0」 .net
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的圖形操做界面,不能夠關閉命令窗口)code
使用:參考 http://blog.csdn.net/liuxiao723846/article/details/52670046htm
一、添加線程組:blog
測試計劃 -> 添加 -> Threads(User) -> 線程組
線程數:表示將模擬多少個用戶進行測試。
Ramp-Up Period(in seconds):線程啓動間隔,全部線程將在這個時間內依次啓動。
循環次數:全部線程執行一次爲一次循環。
若是線程數爲200 ,循環次數爲10 ,那麼每一個線程發送10次請求。總請求數爲200*10=2000 。若是勾選了「永遠」,那麼全部線程會一直髮送請求,直到選擇中止運行腳本。
二、添加採樣器:
採樣器可理解爲針對前面建立的線程須要作什麼事情,這裏以添加HTTP請求爲例。
線程組 -> 添加 -> Sampler -> TCP請求
三、添加監視器
監視器能夠理解爲針對結果的不一樣查看方式。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":""}}