《LoadRunner 12七天速成宝典》—第2章2.6节第二个性能测试案例

本节书摘来自异步社区《LoadRunner 12七天速成宝典》一书中的第2章,第2.6节第二个性能测试案例,作者陈霁,更多章节内容可以访问云栖社区“异步社区”公众号查看。

2.6 第二个性能测试案例
云云:烤鱼吃得很爽。

恋恋:就是你非要吃香辣味的,害得我嘴巴都麻了。

云云:香辣味的好吃,就是鲶鱼吃得有点腻,能吃黑鱼就好了。

恋恋:下次多找几个人一起吃饭啊,这下他们生意就更好了。

云云:那么我问你一下点一样的鱼和点不同的鱼有什么区别?

恋恋:嘿,你又要考我啦,其实刚才你还没提问,我脑子里面就在想这个问题了。

云云:哦,美美狗开窍了?

恋恋:不但我是美美狗还是聪聪狗,你那点小花样我早看出来了。

云云:那么你说说,让我欣赏一下你的“光芒”。

恋恋:这个问题按照你的思路,我可以先从我公司门口的食堂说起,一般食堂都有固定的菜色,因为烧同样的东西处理能力强、成本低,而如果为每一个顾客单独炒菜,那么成本就会高很多。

云云:你这个跑题有点远啊!

恋恋:所以作为顾客,我们一般几个人都点相同的菜,这样厨子烧的快,无论从配菜,到烧菜都会并行处理。总的来说就是,如果每个人都要不同的东西,会让一个饭店很忙,处理能力降低,而如果要的东西类似,那么就会极大地提高处理效率,从而增加营业额。

云云:哎哟,貌似靠谱了。

恋恋:作为软件系统来说也是这样,如果每次对服务器发出的请求不同,那么服务器也会为每一个请求单独计算,从而会让服务器很忙,提高效率就是要让客户做的事情尽量相同,然后服务器就可以并行处理了。

云云:嗯,不错,不过有些不太专业。

恋恋:比如A和B做相同的请求,那么对于数据库来说查询的内容都相同,那么就可以只计算一次,然后内容就可以一次发给客户啦,就好像两个人都点宫保鸡丁炒饭一样,一次炒制,两盘出锅。

云云:虽然请求相同,但是可能因为业务不同而导致结果不同啊,比如A是管理员能看所有的记录,而B是普通用户只能看自己的记录!

恋恋:这个……

云云:那你觉得请求应该相同还是不相同呢?

恋恋:我觉得请求应该不同,因为你既然让我把脚本动起来,还给我说怎么做参数变量、处理业务,本质上就是要让每次输入的东西都不一样。

云云:没错,如果每次请求都一样,那么服务器会自动使用Cache机制,这也是一个使服务器提高处理能力的策略,当发现请求或者查询内容相同,系统会先从缓存(内存)中查找是否存在匹配的记录,如果有就返回,否则就执行一次,将结果存放入缓存,唯一特例就是所谓的要做及时查询,就是锁概念。

恋恋:嗯,我也听说过什么MemCache、PGA&SGA还有啥JVM内存管理,都是和缓存有关系,锁这个概念我就不太懂了。

云云:锁这个概念怎么说呢,这样吧,你知道12306买火车票难吧。

恋恋:知道啊,不知道谁做那么差个系统,查个火车票都经常刷不出来。

云云:这就叫做外行看热闹,内行看门道。其实做火车订票系统是很难的,因为查票是及时的,要锁定票。

恋恋:Go on!

云云:每当一张票被订的时候,所有的查询都要得到全新的少了一张票的情况,所有的订票都要告诉别人这个位置的这个票已经被订了。所以当成千上万的人去买票的时候,一张票被锁定会影响几万个查询,每次查询都不能用Cache,否则会得到错误的信息,你明明看到这个票有,但是订的时候却失败。

恋恋:Go on!

云云:这里面还有更复杂的业务,比如从上海到北京的高铁,如果我订了一张从南京到天津的票,就意味着会多一张上海到南京的票,还有一张从天津到北京的票!

恋恋:那么怎么优化呢?

云云:很简单,首先不要做及时查询,例如不要直接给每个客户看有多少张剩票,其次当一张票订了后,不要立即计算出可能导致生成的部分路程的票,最后将坐全程的票和坐半程的票位置分开做表分离,这样就算买了半程票影响的记录会比较少,处理起来相对简单,让专门的服务器去处理多程票!

恋恋:来吃个梨,你看又进入状态了吧,后面一个人就亢奋的说啊说啊,完全不管别人懂不懂。

云云:真是好心没有好报,看在你给我削梨的举动上就原谅你了。睡觉前是不是可以做第二个性能测试案例了啊。

恋恋:今天晚上要做啥啊?

云云:做一个脚本比较一下点击相同的帖子和点击不同的帖子的性能有何区别!

恋恋:好,开工。

**小结
理解动态访问会带来的负载点及系统处理业务的逻辑概念。
录制脚本运行
**
恋恋:打开LR启动VuGen录制一个脚本。

云云:别忘了你首先要有那么多帖子,否则你查询不到。

恋恋:对,那么先录一个生成帖子的脚本吧。

(几分钟过去后)

恋恋:脚本生成。

Action()
{int i;web_add_cookie("38We_2132_sid=NDgF6W; DOMAIN=127.0.0.1");web_add_cookie("38We_2132_lastvisit=1462200716; DOMAIN=127.0.0.1");web_add_cookie("38We_2132_lastact=1462204316%09home.php%09misc; DOMAIN=127.0.0.1");web_add_cookie("38We_2132_onlineusernum=1; DOMAIN=127.0.0.1");web_add_cookie("38We_2132_sendmail=1; DOMAIN=127.0.0.1");web_url("discuz", "URL=http://127.0.0.1/discuz/", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t2.inf", "Mode=HTML", EXTRARES, "Url=static/image/common/background.png", "Referer=http://127.0.0.1/discuz/forum. php", ENDITEM, "Url=static/image/common/search.gif", "Referer=http://127.0.0.1/discuz/forum.php", ENDITEM, "Url=static/image/common/chart.png", "Referer=http://127.0.0.1/discuz/forum.php", ENDITEM, "Url=static/image/common/px.png", "Referer=http://127.0.0.1/discuz/forum.php", ENDITEM, "Url=static/image/common/qmenu.png", "Referer=http://127.0.0.1/discuz/forum.php", ENDITEM, "Url=static/image/common/nv.png", "Referer=http://127.0.0.1/discuz/forum.php", ENDITEM, "Url=static/image/common/titlebg.png", "Referer=http://127.0.0.1/discuz/forum. php", ENDITEM, "Url=static/image/common/nv_a.png", "Referer=http://127.0.0.1/discuz/forum.php",   ENDITEM, "Url=static/image/common/cls.gif", "Referer=http://127.0.0.1/discuz/forum.php",   ENDITEM, LAST);web_submit_data("member.php", "Action=http://127.0.0.1/discuz/member.php?mod=logging&action=login&loginsubmit   =yes&infloat=yes&inajax=1", "Method=POST", "TargetFrame=", "RecContentType=text/html", "Referer=http://127.0.0.1/discuz/forum.php", "Snapshot=t3.inf", "Mode=HTML", ITEMDATA, "Name=fastloginfield", "Value=username", ENDITEM, "Name=username", "Value=admin", ENDITEM, "Name=password", "Value=123456", ENDITEM, "Name=quickforward", "Value=yes", ENDITEM, "Name=handlekey", "Value=ls", ENDITEM, "Name=questionid", "Value=0", ENDITEM, "Name=answer", "Value=", ENDITEM, LAST);web_add_cookie("38We_2132_lastact=1462204476%09forum.php%09; DOMAIN=127.0.0.1");web_url("forum.php", "URL=http://127.0.0.1/discuz/forum.php", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1/discuz/forum.php", "Snapshot=t4.inf", "Mode=HTML", EXTRARES, "Url=uc_server/images/noavatar_small.gif", ENDITEM, "Url=static/image/common/user_online.gif", ENDITEM, "Url=static/image/common/arrwd.gif", ENDITEM, LAST);web_add_cookie("38We_2132_checkpm=1; DOMAIN=127.0.0.1");web_add_cookie("38We_2132_smile=1D1; DOMAIN=127.0.0.1");web_url("默认版块", "URL=http://127.0.0.1/discuz/forum.php?mod=forumdisplay&fid=2", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1/discuz/forum.php", "Snapshot=t5.inf", "Mode=HTML", EXTRARES, "Url=data/cache/style_1_forum_moderator.css?z69", "Referer=http://127.0.0.1/   discuz/forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/smile.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/sad.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/cry.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/biggrin.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/shocked.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/huffy.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/shy.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/tongue.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/mad.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/titter.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/sweat.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/loveliness.gif", "Referer=http://127.0.0.1/   discuz/forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/funk.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/lol.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/curse.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/hug.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/sleepy.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/time.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/dizzy.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/shutup.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/victory.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/kiss.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/call.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/smiley/default/handshake.gif", "Referer=http://127.0.0.1/   discuz/forum.php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/pt_icn.png", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/arw_r.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/fav.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/arw_l.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/feed.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/pt_item.png", "Referer=http://127.0.0.1/discuz/forum.   php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/recyclebin.gif", "Referer=http://127.0.0.1/discuz/forum.   php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/atarget.png", "Referer=http://127.0.0.1/discuz/forum.   php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/editor/editor.gif", "Referer=http://127.0.0.1/discuz/forum.   php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/mdly.png", "Referer=http://127.0.0.1/discuz/forum.   php?mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/pollsmall.gif", "Referer=http://127.0.0.1/discuz/forum.   php?mod=forumdisplay&fid=2", ENDITEM, LAST);web_add_cookie("38We_2132_editormode_e=1; DOMAIN=127.0.0.1");web_url("高级模式", "URL=http://127.0.0.1/discuz/forum.php?mod=post&action=newthread&fid=2", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1/discuz/forum.php?mod=forumdisplay&fid=2", "Snapshot=t6.inf", "Mode=HTML", EXTRARES, "Url=static/image/common/card_btn.png", "Referer=http://127.0.0.1/discuz/forum.   php?mod=post&action=newthread&fid=2", ENDITEM, "Url=static/image/common/notice.gif", "Referer=http://127.0.0.1/discuz/forum.   php?mod=post&action=newthread&fid=2", ENDITEM, "Url=static/image/common/upload.swf?site=/discuz/misc.php%3fmod=swfupload%26type   =image%26fid=2&type=image&random=O2WM", "Referer=http://127.0.0.1/discuz/forum.   php?mod =post&action=newthread&fid=2", ENDITEM, "Url=static/image/common/upload.swf?site=/discuz/misc.php%3fmod=swfupload%26fid   =2&random=pm3E", "Referer=http://127.0.0.1/discuz/forum.php?mod=post&action=   newthread&fid=2", ENDITEM, LAST);for(i=0;i<1000;i++){web_submit_data("forum.php_2", "Action=http://127.0.0.1/discuz/forum.php?mod=post&action=newthread&fid=2&extra   =&topicsubmit=yes", "Method=POST", "TargetFrame=", "RecContentType=text/html", "Referer=http://127.0.0.1/discuz/forum.php?mod=post&action=newthread&fid=2", "Snapshot=t7.inf", "Mode=HTML", ITEMDATA, "Name=formhash", "Value=27ad1fe9", ENDITEM, "Name=posttime", "Value=1462204484", ENDITEM, "Name=wysiwyg", "Value=1", ENDITEM, "Name=subject", "Value=第二天测试专用{topic}", ENDITEM, "Name=message", "Value=美美狗代表云层天咨发帖了{topic}", ENDITEM, "Name=save", "Value=", ENDITEM, "Name=uploadalbum", "Value=", ENDITEM, "Name=newalbum", "Value=", ENDITEM, "Name=readperm", "Value=", ENDITEM, "Name=price", "Value=", ENDITEM, "Name=usesig", "Value=1", ENDITEM, "Name=allownoticeauthor", "Value=1", ENDITEM, EXTRARES, "Url=uc_server/images/noavatar_middle.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=viewthread&tid=868&extra=", ENDITEM, "Url=data/cache/style_1_forum_viewthread.css?z69", "Referer=http://127.0.0.1/   discuz/forum.php?mod=viewthread&tid=868&extra=", ENDITEM, "Url=static/js/forum_viewthread.js?z69", "Referer=http://127.0.0.1/discuz/forum.   php?mod=viewthread&tid=868&extra=", ENDITEM, LAST);}web_custom_request("home.php", "URL=http://127.0.0.1/discuz/home.php?mod=spacecp&ac=pm&op=checknewpm&rand   =1462204515", "Method=GET", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1/discuz/forum.php?mod=viewthread&tid=868&extra=", "Snapshot=t8.inf", "Mode=HTML", "EncType=application/x-www-form-urlencoded", EXTRARES, "Url=static/image/common/flbg.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=viewthread&tid=868&extra=", ENDITEM, "Url=static/image/common/rec_add.gif", "Referer=http://127.0.0.1/discuz/forum.  php? mod=viewthread&tid=868&extra=", ENDITEM, "Url=static/image/common/oshr.png", "Referer=http://127.0.0.1/discuz/forum.php?   mod=viewthread&tid=868&extra=", ENDITEM, "Url=static/image/common/rec_subtract.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=viewthread&tid=868&extra=", ENDITEM, "Url=static/image/common/fastreply.gif", "Referer=http://127.0.0.1/discuz/ forum.  php?mod=viewthread&tid=868&extra=", ENDITEM, "Url=static/image/common/midavt_shadow.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=viewthread&tid=868&extra=", ENDITEM, "Url=static/image/common/repquote.gif", "Referer=http://127.0.0.1/discuz/ forum.  php?mod=viewthread&tid=868&extra=", ENDITEM, "Url=static/image/common/edit.gif", "Referer=http://127.0.0.1/discuz/ forum.php?  mod=viewthread&tid=868&extra=", ENDITEM, "Url=static/image/common/popupcredit_bg.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=viewthread&tid=868&extra=", ENDITEM, LAST);return 0;
}

恋恋:这里我用了一个循环,做了1000次。

云云:那么你发帖的那个参数是?

恋恋:{topic}啊,这是我定义的一个时间参数,这样每次帖子都不一样,如图2-23所示。


22e7ba550c6d943340b58b55639124aac2b262f3

云云:哎哟,不错哦。

恋恋:好了,单击运行,我去给你削个梨。

云云:好!不过,如果你用场景,运行会快一些。

恋恋:好啊,你自己削梨去,EQ真低。

云云:我错了,还是你帮我削吧。

(几分钟后,帖子生成)如图2-24所示。


6ff47e29ed6b3692189540fa54e22f2d4c3565f9

恋恋:接着我要录制一个用户随机访问帖子的脚本和一个用户访问一个固定帖子的脚本。
Action()
{web_url("discuz", "URL=http://127.0.0.1/discuz/", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t1.inf", "Mode=HTML", EXTRARES, "Url=static/image/common/background.png", "Referer=http://127.0.0.1/discuz/forum.   php", ENDITEM, "Url=static/image/common/search.gif", "Referer=http://127.0.0.1/discuz/forum.php",   ENDITEM, "Url=static/image/common/nv.png", "Referer=http://127.0.0.1/discuz/forum.php",   ENDITEM, "Url=static/image/common/px.png", "Referer=http://127.0.0.1/discuz/forum.php",   ENDITEM, "Url=static/image/common/titlebg.png", "Referer=http://127.0.0.1/discuz/forum.   php", ENDITEM, "Url=static/image/common/nv_a.png", "Referer=http://127.0.0.1/discuz/forum.php",   ENDITEM, "Url=static/image/common/qmenu.png", "Referer=http://127.0.0.1/discuz/forum.php",   ENDITEM, "Url=static/image/common/chart.png", "Referer=http://127.0.0.1/discuz/forum.php",   ENDITEM, LAST);lr_think_time(5);web_url("默认版块", "URL=http://127.0.0.1/discuz/forum.php?mod=forumdisplay&fid=2", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1/discuz/forum.php", "Snapshot=t2.inf", "Mode=HTML", EXTRARES, "Url=static/image/common/pt_icn.png", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/pt_item.png", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/arrwd.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/fav.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/feed.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/arw_l.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/arw_r.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/atarget.png", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/editor/editor.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, LAST);lr_think_time(4);web_url("第二天测试专用2016-05-03 00:09:10.850", "URL=http://127.0.0.1/discuz/forum.php?mod=viewthread&tid=1867&extra=page%3D1", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1/discuz/forum.php?mod=forumdisplay&fid=2", "Snapshot=t3.inf", "Mode=HTML", EXTRARES, "Url=uc_server/images/noavatar_middle.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, "Url=static/image/common/oshr.png", "Referer=http://127.0.0.1/discuz/forum.php?   mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, "Url=static/image/common/rec_add.gif", "Referer=http://127.0.0.1/discuz/forum.  php? mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, "Url=static/image/common/midavt_shadow.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, "Url=static/image/common/fastreply.gif", "Referer=http://127.0.0.1/discuz/forum.   php?mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, "Url=static/image/common/rec_subtract.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, "Url=static/image/common/flbg.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, "Url=static/image/common/repquote.gif", "Referer=http://127.0.0.1/discuz/forum.   php?mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, LAST);return 0;
}

恋恋:找到看帖请求的那个函数,然后将这个请求内容做一个参数化,参数名称叫作tid,并且设置从1~1000的随机数,如图2-25所示。


387ef287a655181cd1840368ba7f9852fbc1eae7
Action()
{web_url("discuz", "URL=http://127.0.0.1/discuz/", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t1.inf", "Mode=HTML", EXTRARES, "Url=static/image/common/background.png", "Referer=http://127.0.0.1/discuz/forum.   php", ENDITEM, "Url=static/image/common/search.gif", "Referer=http://127.0.0.1/discuz/forum.php",   ENDITEM, "Url=static/image/common/nv.png", "Referer=http://127.0.0.1/discuz/forum.php",   ENDITEM, "Url=static/image/common/px.png", "Referer=http://127.0.0.1/discuz/forum.php",   ENDITEM, "Url=static/image/common/titlebg.png", "Referer=http://127.0.0.1/discuz/forum.   php", ENDITEM, "Url=static/image/common/nv_a.png", "Referer=http://127.0.0.1/discuz/forum.php",   ENDITEM, "Url=static/image/common/qmenu.png", "Referer=http://127.0.0.1/discuz/forum.php",   ENDITEM, "Url=static/image/common/chart.png", "Referer=http://127.0.0.1/discuz/forum.php",   ENDITEM, LAST);lr_think_time(5);web_url("默认版块", "URL=http://127.0.0.1/discuz/forum.php?mod=forumdisplay&fid=2", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1/discuz/forum.php", "Snapshot=t2.inf", "Mode=HTML", EXTRARES, "Url=static/image/common/pt_icn.png", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/pt_item.png", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/arrwd.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/fav.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/feed.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/arw_l.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/arw_r.gif", "Referer=http://127.0.0.1/discuz/ forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/atarget.png", "Referer=http://127.0.0.1/discuz/forum.  php? mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/editor/editor.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, LAST);lr_think_time(4);web_url("第二天测试专用2016-05-03 00:09:10.850", "URL=http://127.0.0.1/discuz/forum.php?mod=viewthread&tid={tid}&extra=page%3D1", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1/discuz/forum.php?mod=forumdisplay&fid=2", "Snapshot=t3.inf", "Mode=HTML", EXTRARES, "Url=uc_server/images/noavatar_middle.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, "Url=static/image/common/oshr.png", "Referer=http://127.0.0.1/discuz/forum.php?   mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, "Url=static/image/common/rec_add.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, "Url=static/image/common/midavt_shadow.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, "Url=static/image/common/fastreply.gif", "Referer=http://127.0.0.1/discuz/forum.   php?mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, "Url=static/image/common/rec_subtract.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, "Url=static/image/common/flbg.gif", "Referer=http://127.0.0.1/discuz/forum. php?   mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, "Url=static/image/common/repquote.gif", "Referer=http://127.0.0.1/discuz/forum.   php?mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, LAST);return 0;
}

恋恋:最后还要在查询前后加个事务,让脚本运行的时候能够统计响应时间,先来试着运行一下。

Action()
{web_url("discuz", "URL=http://127.0.0.1/discuz/", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t1.inf", "Mode=HTML", EXTRARES, "Url=static/image/common/background.png", "Referer=http://127.0.0.1/discuz/forum.   php", ENDITEM, "Url=static/image/common/search.gif", "Referer=http://127.0.0.1/discuz/forum.php",   ENDITEM, "Url=static/image/common/nv.png", "Referer=http://127.0.0.1/discuz/forum.php",   ENDITEM, "Url=static/image/common/px.png", "Referer=http://127.0.0.1/discuz/forum.php",   ENDITEM, "Url=static/image/common/titlebg.png", "Referer=http://127.0.0.1/discuz/forum.   php", ENDITEM, "Url=static/image/common/nv_a.png", "Referer=http://127.0.0.1/discuz/forum.php",   ENDITEM, "Url=static/image/common/qmenu.png", "Referer=http://127.0.0.1/discuz/forum.php",   ENDITEM, "Url=static/image/common/chart.png", "Referer=http://127.0.0.1/discuz/forum.php",   ENDITEM, LAST);lr_think_time(5);web_url("默认版块", "URL=http://127.0.0.1/discuz/forum.php?mod=forumdisplay&fid=2", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1/discuz/forum.php", "Snapshot=t2.inf", "Mode=HTML", EXTRARES, "Url=static/image/common/pt_icn.png", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/pt_item.png", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/arrwd.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/fav.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/feed.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/arw_l.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/arw_r.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/common/atarget.png", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, "Url=static/image/editor/editor.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=forumdisplay&fid=2", ENDITEM, LAST);lr_think_time(4);lr_start_transaction("viewtopic");web_url("第二天测试专用2016-05-03 00:09:10.850", "URL=http://127.0.0.1/discuz/forum.php?mod=viewthread&tid={tid}&extra=page%3D1", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1/discuz/forum.php?mod=forumdisplay&fid=2", "Snapshot=t3.inf", "Mode=HTML", EXTRARES, "Url=uc_server/images/noavatar_middle.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, "Url=static/image/common/oshr.png", "Referer=http://127.0.0.1/discuz/forum.php?   mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, "Url=static/image/common/rec_add.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, "Url=static/image/common/midavt_shadow.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, "Url=static/image/common/fastreply.gif", "Referer=http://127.0.0.1/discuz/ forum.   php?mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, "Url=static/image/common/rec_subtract.gif", "Referer=http://127.0.0.1/discuz/   forum.php?mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, "Url=static/image/common/flbg.gif", "Referer=http://127.0.0.1/discuz/forum.php?   mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, "Url=static/image/common/repquote.gif", "Referer=http://127.0.0.1/discuz/forum.   php?mod=viewthread&tid=1867&extra=page%3D1", ENDITEM, LAST);
lr_end_transaction("viewtopic", LR_AUTO);return 0;
}

恋恋:代码运行大功告成!

云云:值得表扬!

(分别运行未参数化和参数化过的脚本)。

恋恋:好像查询条件是随机的会慢一点。

云云:Go On。

恋恋:OK,搞定两个脚本,一个是原脚本,查询条件不变的;还有一个是查询条件是随机的内容,接着分别到场景里面去运行一下。

恋恋:场景里面要添加监控内容(Windows资源),单击开始运行。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/258918.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

MongoDB_1

突然想去看下MongoDB的东西&#xff0c;于是有了这篇文章。其实很早以前就看过一些关于NoSql的文章&#xff0c;还记得当时里面有介绍MongoDB的&#xff0c;多瞅了2眼&#xff0c;并且在Window下安装了MongoDB的驱动&#xff0c;小玩了会。今天重新翻出来&#xff0c;没成想在命…

pyqt5从子目录加载qrc文件_实战PyQt5: 045-添加资源文件

添加资源文件在使用PyQt进行图形界面开发的时候不免要用到一些外部资源&#xff0c;比如图片&#xff0c;qss配置文件等。在前面代码中&#xff0c;遇到这类问题&#xff0c;我们使用绝对路径的方式来解决&#xff0c;这种方式&#xff0c;本身有其不方便之处(比如&#xff0c;…

西门子ddc_铁门关西门子两通电动阀VVF42.25-10C+SKD60西

铁门关西门子两通电动阀西SIEMENS/西门子电动温控阀、控制箱、电动蝶阀、电动球阀、超声波热量表、超声波流量计、电磁流量计阀体灰口铸铁 EN-GJL-2502.霍尼韦尔主营&#xff1a;楼宇资料系统、热网自控系统、风机盘管电动两通阀、空气压差开关、水流开关、电动执行器、风阀执行…

JS-键盘事件之方向键移动元素

注意三点&#xff1a; 1&#xff1a;事件名称onkeydown。 2&#xff1a;事件加给document&#xff0c;而非window。 3&#xff1a; 把元素的top&#xff0c;left值分别用offsetTop&#xff0c;offsetLeft来设定。 <!DOCTYPE html> <html><head><meta char…

Swift学习字符串、数组、字典

一.字符串的使用 let wiseWords "\"I am a handsome\"-boy" var emptyString "" if emptyString.isEmpty{ println("这是一个空值") }简单说明&#xff1a;isEmpty方法是用来判断字符串是否为空值的&#xff0c;之后会执行if语句中的…

python对excel操作简书_Python读写Excel表格,就是这么简单粗暴又好用

最近在做一些数据处理和计算的工作&#xff0c;因为数据是以.CSV格式保存的&#xff0c;因此刚开始直接用Excel来处理。 但是做着做着发现重复的劳动&#xff0c;其实并没有多大的意义&#xff0c;于是就想着写个小工具帮着处理。 以前正好在一本书上看到过&#xff0c;使用Pyt…

halcon/c++接口基础 之 halcon初认识

从今天开始&#xff0c;开始更新博客&#xff0c;主要分享自己最近正在翻译的Halcon/C教程。先给出第一篇文章&#xff0c;由于此文章&#xff0c;是用latex写的&#xff0c;直接导成html&#xff0c;保存在七牛云存储上&#xff0c;所以直接点击链接就看到&#xff0c;后面我将…

指数型组织形成的 9 大驱动因素

指数时代&#xff0c;是一个前所未有的激动人心的世界。 Airbnb, 谷歌, 亚马逊和GitHub这些知名的公司&#xff0c;都有一个让人称羡的共同点&#xff0c;那就是——他们都是非常成功的指数型组织&#xff08;Exponential Organizations&#xff0c;ExO’s&#xff09;。 “在当…

mysqld:表mysql.plugin不存在_99%测试工程师不知道的数据库知识|干货

点击上方“蓝字”关注我们数据库&#xff0c;简而言之可视为电子化的文件柜——存储电子文件的处所&#xff0c;用户可以对文件中的数据进行新增、查询、更新、删除等操作。所谓“数据库”是以一定方式储存在一起、能与多个用户共享、具有尽可能小的冗余度、与应用程序彼此独立…

Windows Phone 执行模型概述

Windows Phone 执行模型控制在 Windows Phone 上运行的应用程序的生命周期&#xff0c;该过程从启动应用程序开始&#xff0c;直至应用程序终止。 该执行模型旨在始终为最终用户提供快速响应的体验。为此&#xff0c;在任何给定时间内&#xff0c;Windows Phone 仅允许一个应用…

halcon/c++接口基础 之 构造函数与Halcon算子

Halcon/C提供了构造函数&#xff0c;主要基于适合的Halcon算子。比如说HImage和HBarCode基于read_image and create_bar_code_model。 请注意当前的Halcon版本针对不同的算子构造函数的功能不同。如下我们介绍了一些最常用的Halcon算子&#xff0c;而一个完整的构造函数列表可…

bat自动输入用户名和密码_「小白到大牛之路6」交换机后台管理之重复输入用户名和密码...

项目需求解决项目5中存在的问题&#xff1a;用户名和密码只能输入一次。如果输入错误&#xff0c;就没有机会重新输入。项目实现#include int main(void) {// 定义变量&#xff0c;用来表示用户名和密码char name[32];char password[16];//输入用户名和密码while (1) {// 输入用…

halcon/c++接口基础 之 析构函数和Halcon算子

所有的HALCON/C类都提供了默认的析构函数用来自动销毁对应的内存。对于某些类&#xff0c;析构函数基于适合的算子&#xff1a; Windows: HWindow类的析构函数基于close_window关闭窗口。注意&#xff1a;算子本身不是析构器。你可以选择调用CloseWindow关闭窗口&#xff0c;…

ios 上传图片到阿里云的oss_JEECG BOOT 上传如何同时支持阿里OSS、Minio、本地存储

Jeecg-Boot 提供了文件及图片上传功能&#xff0c;前两个文件已介绍了MinIO和OSS配置&#xff0c;现在可根据需要选择上传方式。文件上传接口(图片/文件)在yml文件中可切换图片/文件存储方式访问路径上送参数说明在yml文件中可切换图片/文件存储方式local为本地存储minio为使用…

halcon/c++接口基础 之内存管理

所有的HALCON类&#xff0c;不仅仅HImage,HRegion,HTuple&#xff0c;HFramegrabber等等&#xff0c;还有面向过程的方法中使用的Hobject&#xff0c;都可以使用默认的析构器自动释放内存。 &#xff08; see also section 2.4 “Destructors and Halcon Operators”)&#xf…

python时间格式_python 格式化日期

常用的时间函数如下 获取当前日期&#xff1a;time.time() 获取元组形式的时间戳&#xff1a;time.local(time.time()) 格式化日期的函数(基于元组的形式进行格式化)&#xff1a; &#xff08;1&#xff09;time.asctime(time.local(time.time())) &#xff08;2&#xff09;ti…

halcon/c++接口基础 之异常处理

关于运行错误&#xff0c;HALCON/C默认打印错误信息并且终止程序。然而在某些应用中&#xff0c;放宽这个法则可能更有用。比如&#xff0c;如果一个应用要求用户交互式地指定一个图像文件读取&#xff0c;如果因为用户不能拼错文件名而终止程序的话&#xff0c;会很不方便。因…

SVN学习(二)——SVN 提交、更新、解决冲突等操作步骤

1. 纳入版本控制 ①新建文件abc.txt ②在文件上点右键 ③添加后文件图标发生变化 2. 提交 ①使用TortoiseSVN可以提交具体某一个文件&#xff0c;或某一个目录下的所有改变。方法就是在想要提交的项目下点右键&#xff0c;然后SVN Commit...&#xff0c;就可以看到如下界面 ②日…

dat文件打开乱码_5.2 实战1:解决在Linux下打开Windows汉字文本的乱码问题

今天MK继续来分享linux的学习文章&#xff0c;今天讲的主要是实战部分。1&#xff0e;实验环境&#xff1a;CentOS 7.5 现在系统默认使用的语言是汉语。&#xff08;系统中必须安装好中文包&#xff09;。2&#xff0e;在windows系统上编辑名字为“a此文件在windows下打开正常-…

整理:深度学习 vs 机器学习 vs 模式识别

发表于2015-03-24 22:58| 11934次阅读| 来源个人博客| 26 条评论| 作者Tomasz Malisiewicz 模式识别深度学习机器学习数据科学家摘要&#xff1a;本文我们来关注下三个非常相关的概念&#xff08;深度学习、机器学习和模式识别&#xff09;&#xff0c;以及他们与2015年最热门的…