好处是可以对一组url进行测试
  参见 http://www.blogjava.net/crespochen/archive/2009/06/02/279573.htmlhttp://baike.baidu.com/link?url=Uv0KtwM83hvFTjudQsP37FIfeUDJxMW4Kvodfk6oSTJ4B4ctpr1R6P4CGXdyMExyU7rGL2bold_aGJHwKaV2l_
  郭扬提供了1.73上的应用,拷贝到/guodian/uap2,部署上Weblogic的Server-0(端口号是7010)。uap2依赖于uap_server。通过http访问是
  查询
  http://192.168.1.73:7010/sguap-client/SmallCase/rest/smallCase/
  增加:
  http://192.168.1.73:7010/sguap-client/SmallCase/rest/smallCase/insert?uuid=XXX&name=XXX
  修改:
  http://192.168.1.73:7010/sguap-client/SmallCase/rest/smallCase/update?uuid=XXX&name=XXX
  删除
  http://192.168.1.73:7010/sguap-client/SmallCase/rest/smallCase/delete?uuid=XXX
  我们在1.74上做测试。
  yum -y install siege #安装siege,安装不上的话,从前面提供的URL上下载siege,再安装。
  据此,写了个shell生成url
#!/bin/bashfunction get_random_name(){MATRIX="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"LENGTH=8while[${n:=1}-le$LENGTH]; doPASS="$PASS${MATRIX:$(($RANDOM%${#MATRIX})):1}"let n+=1doneecho$PASS}function make_link(){act=$1#echo $actfor i in$seqc; do#echo $i
linkarr[$i]="$link/$act?uuid=${idarr[$i]}&name=$(get_random_name)"echo${linkarr[$i]}>>$outdone}num=$1out=$2[ x$num = x ]&&num=10[ x$out = x ]&&out=link.out
link=http://192.168.1.73:7010/sguap-client/SmallCase/rest/smallCase
declare-a idarr
seqc=`seq$num`for i in$seqc; do
idarr[$i]=$[$RANDOM%1000]doneecholink=$link>$outecho${idarr[@]}declare-a linkarr
$(make_link insert);
echo $link/>>$outecho>>$out
$(make_link update);
echo $link/>>$outecho>>$out
$(make_link delete);
echo $link/>>$outecho>>$out
  测试命令
  siege -c20 -r2 -f link.out
  参数说明:
  -c20 并发20个用户
  -r2 重复循环2次
  -f link.out 任务列表:URL列表
  测试结果:
** SIEGE 3.0.0
** Preparing 20 concurrent users for battle.
The server is now under siege...
HTTP/1.1 200   0.37 secs:     340 bytes ==> GET  /sguap-client/SmallCase/rest/smallCase/insert
HTTP/1.1 200   0.38 secs:     340 bytes ==> GET  /sguap-client/SmallCase/rest/smallCase/insert
...............................................  #代替很多条HTTP/1.1 ...
Transactions:          40 hits
Availability:      100.00 %
Elapsed time:        2.14 secs
Data transferred:        0.01 MB
Response time:        0.21 secs
Transaction rate:       18.69 trans/sec
Throughput:        0.01 MB/sec
Concurrency:        3.87
Successful transactions:          40
Failed transactions:           0
Longest transaction:        0.58
Shortest transaction:        0.00
  Concurrency是并发数
  siege还包含了一些辅助工具:bombardment,是一个辅助工具:用于按照增量用户压力测试。
  bombardment link.out 5 5 10 1
  这样测试,效果也良好,是费时间。