对软件进行 性能测试,需要写一个脚本来作驱动。
基本要求如下:
(1)每秒钟能并发M次;
(2)可以连续不断地执行N秒;
#需要并发执行的脚本 driver.pl
#每秒并发执行M次的脚本 MperSec.ksh
#! /usr/bin/ksh
# usage: MperSec.ksh M
MperSec= # is how many times per second
time{
for ((i=1;i<=$MperSec;i ))
do
driver.pl & # & means let the script run in background
done
wait
}
#连续执行N秒的脚本 NSecs.ksh
#! /usr/bin/ksh
#usage: NSecs.ksh N M
NSecs=
MperSecond=
for ((i=1;i<=$NSecs;i ))
do
MperSec.ksh& # & means let the script run in background
sleep 1
done
#How to invoke the whole test process
NSecs.ksh 7200 6 |tee test.log
#----------------经过测试的版本----------------------------------
# Solaris 9 ksh
#! /usr/bin/ksh
# usage: MperSec.ksh M
MperSec="" # is how many times per second
function func
{
i=1
while [ "$i" -lt "$MperSec" ]
do
driver.pl & # & means let the script run in background
i=$(($i 1))
done
wait
}
time func
#(time func) 2>&1|awk '/real/{print }'
#! /usr/bin/ksh
# usage: MperSec.ksh M
MperSec="" # is how many times per second
function func
{
i=1
while [ "$i" -lt "$MperSec" ]
do
ipqueryClient.pl & # & means let the script run in background
i=$(($i 1))
done
wait
}
time func
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




