前言
我們經常會用loadrunner來做性能測試,但有時候loadrunner沒法完成一些性能測試,這時候就需要其他工具了,今天就給大家介紹一個autobench。
簡介
autobench 是一款基于httperf的Perl腳本。它會在一次測試中調用多次httperf來對web伺服器進行測試,每次會按照給定的參數增加并發連接配接數,将httperf的測試結果儲存為CSV格式的檔案,該檔案可以被Excel直接讀取,友善生成測試報告。借助于autobench自帶的bench2graph工具可以生成漂亮的測試結果對比圖。
1、先安裝Httperf
下載下傳:http://code.google.com/p/httperf/downloads/list
tar xvzf httperf-0.9.0.tar.gz
cd httperf-0.9.0
./configure
make && make install
2、安裝gnuplot
下載下傳:http://www.gnuplot.info/download.html
tar xvzf gnuplot-4.2.0.tar.gz
cd gnuplot-4.2.0
cp /usr/local/bin/bench2graph /usr/local/bin/bench2png
sed -i 's/postscript color/png xffffff/g' /usr/local/bin/bench2png
注意這裡一定要打開:echo set data style linespoints >> gnuplot.cmd
3、安裝autobench
下載下傳:http://www.xenoclast.org/autobench/downloads/autobench-2.1.2.tar.gz
tar xvzf autobench-2.1.2.tar.gz
cd autobench-2.1.2
4、使用
4.1 測試單台主機
./autobench \
--single_host \
--host1=your_ip \
--port1=80 \
--uri1=/home/www/mysql_con.php \
--quiet \
--low_rate=5 \
--high_rate=100 \
--rate_step=5 \
--num_call=5 \
--num_conn=1000 \
--timeout=10 \
--file /tmp/con_results.tsv
4.2 測試多台機器
--host1=your_ip1 \
--host2=your_ip2 \
--port2=80 \
--uri2=/home/www/mysql_pcon.php \
--file /tmp/results.tsv
4.3 參數含義
--signle_host 隻測單機
--host1 測試主機位址
--uri1 host1 測試URI
--quiet 安靜模式
--low_rate 測試時最低請求數(指 httperf)
--hight_rate 測試時最高請求數
--rate_step 每次測試請求數增加步長
--num-call 同httperf
--num_conn 同httperf
--file 測試結果輸出的 tsv檔案
4.4 生成圖檔
bench2png results.tsv results.png
<a href="http://blog.51cto.com/attachment/201205/094117398.png" target="_blank"></a>
本文轉自 小強測試幫 51CTO部落格,原文連結:http://blog.51cto.com/xqtesting/873919,如需轉載請自行聯系原作者