前言

我们经常会用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

./configure

make && make install

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

make && make install

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 测试多台机器

./autobench \

    –host1=your_ip1 \

    –port1=80 \

    –uri1=/home/www/mysql_con.php \

    –host2=your_ip2 \

    –port2=80 \

    –uri2=/home/www/mysql_pcon.php \

    –quiet \

    –low_rate=5 \

    –high_rate=100 \

    –rate_step=5 \

    –num_call=5 \

    –num_conn=1000 \

    –timeout=10 \

    –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