用DOS做简单的Google搜索引擎性能测试

2010-04-23  王廷虎 

    一直做MMOG的测试,没有接触过WEB测试,不知道有专业做搜索引擎性能测试的朋友们是如何做的.
    以下只是练习时的脚本,且依赖于 curl、sed、grep三个命令行程序(这三个是*unix下的大杀器,但都有windows下的命令行版本移植)。
    最终结果输出到 out.csv中,每行为搜索耗费时间以及相应的关键词

::---------------------------------
::by wangth
@echo off
setlocal ENABLEDELAYEDEXPANSION
::定义测试搜索用的字典文件,每个词一行,请勿包含敏感词 - -
set wdfile=wd.txt
set sunit=seconds
if not exist %wdfile% echo 字典文件不存在,请检查.&&pause&&goto end
if exist out.csv del /f /a out.csv
if exist tmp.htm del /f /a tmp.htm
echo 开始测试,当前时间 %date%,%time%
for /f %%i in (%wdfile%) do call :search %%i
goto ok

:search
::curl的命令行,代理服务器和代理服务器账号密码等请根据自己的环境配置,如无可取消相关选项。
curl -x 192.168.1.1:3128 -U wangth:mypassword -A "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)" -o tmp.htm -s http://www.google.com.hk/search?q=%1^&ie=GBK^&hl=en
sed -i "s/[<>\\\%#\/ ]//g" tmp.htm
for /f %%i in ('grep -oE "[0-9]+\.[0-9]+b%sunit%" tmp.htm') do set str=%%i
set str=!str:b%sunit%=!
>>out.csv echo %str%,%1
goto :eof

:ok
echo 测试完成,当前时间 %date%,%time%
pause>nul

:end
if exist tmp.htm del /f /a tmp.htm
::-------------------------------------
388°/3823 人阅读/6 条评论 发表评论

苗志伟  2010-04-24

支持一下,学习中。。。


金鑫  2010-04-24

学习


李波  2010-04-25

学习中


陈运琴  2010-04-25

学习


程守标  2010-04-26

学习


刘小袁  2010-04-29

学习。。。


登录 后发表评论
王廷虎
访客 4933
王廷虎 的其他博文 更多