loadrunner---<三>---菜鸟对Browser Emulation的思考
之前在一个web是项目做性能测试,发现controller中场景运行的时候,mrdv.exe内存所耗内存在不断增加,最后报错停止了
not enough memory for new buffer in LrwSrvNetTaskItem::AllocSrvNetBuf---没有内存了
然后打开analysis中的监控本机的资源图,测试机的内存在不断的较小,一直减小到提示错误,最后内存的 剩余量不记得了。在场景运行的过程中,从任务管理器看,内存也是不断减小。听测试群中的人说这种现象叫:脚本吃内存了
测试的内容是开发部门提供的http接口,不是录制的脚本,就是到数据库中查询,然后对返回状态做判断,判断时候。不需要考虑申请内存再释放内存的问题,脚本中除了事务,检查点没有添加其他的函数,所以,可以肯定不是脚本的问题(此外,从controller中的vuser的show vuser log查找错误出现的位置,有两处,一处是空白行,一处是提交的请求)
在网上搜,发现是Browser Emulation设置的问题,run-time-setting里面的设置有问题
后来将Browser Emulation的选项都禁止,mrdv占用的内存基本不变了,不再增加。
备注:但是测试了一下登陆mail.163.com中Browser Emulation设置,设置了下载非资源文件的选项的情况下,内存占用比较大,但是并没有出现内存占用量不断增加的现象(测试时间约为20分钟),这个问题有待考虑。。。
下面总结一下Browser Emulation
1--什么是浏览器缓存?--
简单来说,浏览器的缓存就是--使用浏览器访问页面时,浏览器会将一些网页的文字,图片,保存到本地的一个文件内。然后,再次使用浏览器访问这个网页的时候,先前被保存(缓存)的文字和图片不会从新被下载,而是使用保存在本地的资源。
Browser Emulation就是用来设置脚本回放时,lr模拟浏览器缓存策略的
缓存的东西一般都放在C:\Documents and Settings\用户\Local Settings\Temporary Internet Files下。可以进去打开立面都是些什么--文档和图片,而且都是你曾经浏览过的界面中信息
2--Browser Emulation选项说明--
详解见:http://www.rosoo.net/a/201011/10401.html
http://hi.baidu.com/c1425/item/0f4af76fc4f3a20ca1cf0f9d
上面这个连接对浏览器的设置,解释的很好,本人尝试了对Browser Emulation各种设置,在脚本回放的时候抓包比对,大体上是正确的。
为了方便描述,我们约定用:
A代表Simulate browser cache
B代表Cache URLs requiring content(HTMLs)
C代表Check for newer versions of stored pages every visit to the page
D代表Download non-HTML resources
E代表Simulate a new user on each iteratioin
F代表Clear cache on each iteration
附上help关于Browser Emulation的中文文档
根据实验总结如下:
1:Download non-HTML resources 下载非HTML资源。在设置了download non-HTML resource后下载了些什么东西?
提交的请求如下:
web_url("ntesdoor2_2", "URL=http://entry.mail.163.com/coremail/fcg/ntesdoor2?lightweight=1&verifycookie=1&language=-1&from=web&df=webmail163", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t3.inf", "Mode=HTML", EXTRARES, "Url=http://mimg.127.net/p/js5/5.0.0b1211141530/----={sid}", ENDITEM, "Url=http://mimg.127.net/p/font/js5/v1/--}", ENDITEM, "Url=http://mimg.127.net/p/t.gif", "----}", ENDITEM, "Url=http://mimg.127.net/xm/all/point_club/webmail/img---.jsp?sid={sid}", ENDITEM, "Url=http://mimg.127.net/p/js5/5.0.0b1211141530/img/skin_163blue/top_right.jpg", "Referer=---?sid={sid}", ENDITEM, "Url=http://mimg.127.net/p/js5/5.0.0b1211141530/img/wel/submit.png",--}", ENDITEM, "Url=http://mimg.127.net/p/js5/5.0.0b1211141530/js/product/music.js", "--main.jsp?sid={sid}", ENDITEM, "Url=http://mimg.127.net/p/js5/5.0.0b1211141530/img/skin_163blue/bg.png", "Referer--/js5/main.jsp?sid={sid}", ENDITEM, "Url=http://mimg.127.net/p/js5/5.0.0b1211141530/--/bgx.png", -?sid={sid}", ENDITEM, LAST);
回放日志如下
没有设置 D
Action.c(71): Redirecting http://entry.mail.163.com/---- (redirection depth is 0) [MsgId: MMSG-26694] Action.c(71): To location "http://twebmail.mail.163.com/---?sid=----" [MsgId: MMSG-26693] Action.c(71): web_url("ntesdoor2_2") was successful, 8048 body bytes, 1786 header bytes, 13 chunking overhead bytes [MsgId: MMSG-26385] Action.c(91): web_add_cookie was successful [MsgId: MMSG-26392] Action.c(93): web_add_cookie was successful [MsgId: MMSG-26392]
设置 D选项,在提交请求的时候下载了很多资源
Action.c(64): Registering web_reg_save_param was successful [MsgId: MMSG-26390] Action.c(69): Registering web_reg_find was successful [MsgId: MMSG-26390] Action.c(71): Redirecting http://entry.mail.163.com/----- (redirection depth is 0) [MsgId: MMSG-26694] Action.c(71): To location "http://twebmail.mail.163.com/js5/main.jsp?sid=----" [MsgId: MMSG-26693] Action.c(71): Found resource "http://mimg.127.net/p/js5/5.0.0b1211141530/css/skin_163blue.css" in HTML "http://twebmail.mail.163.com/js5/main.jsp?sid=RBvmkshsJeynolIpsgssFmmypvBcgtxl" [MsgId: MMSG-26659] Action.c(71): Found resource "http://mimg.127.net/external/js5pd163.js" in HTML http://---.jsp?sid=---mypvBcgtxl [MsgId: MMSG-26659] Action.c(71): Found resource "http://mimg.127.net/external/js5public163.js" in HTML http://twebmail.---=RBvmksh---gs--y--xl [MsgId: MMSG-26659] Action.c(71): Downloading resource http://mimg.127.net/p/js5/5.0.--.css (specified by argument number 10) [MsgId: MMSG-26577] Action.c(71): Downloading resource "http://mimg.127.net/p/font/js5/v1/neteasefont-regular.eot" (specified by argument number 13) [MsgId: MMSG-26577] Action.c(71): Downloading resource "http://mimg.127.net/p/t.gif" (specified by argument number 16) [MsgId: MMSG-26577] Action.c(71): Downloading resource "http://mimg.127.net/xm/all/point_club/webmail/img/-(specified by argument number 22) [MsgId: MMSG-26577] Action.c(71): Downloading resource "http://mimg.127.net/p/js5/5.0.0b1211141530/img/wel/submit.png" (--number 25) [MsgId: MMSG-26577] Action.c(71): Downloading resource http://mimg.127.net/p/js5/5.0.0b1211141530/js/--.js (specified-number 28) [MsgId: MMSG-26577] Action.c(71): Downloading resource http://mimg.127.net/p/js5/5.0.0b1211141530/img/-/bgx.png (specified by argument number 34) [MsgId: MMSG-26577] Action.c(71): Found resource "http://mimg.127.net/logo/163logo.gif" in HTML http://twebmail.mail.163.com/js5/main.jsp?sid=------l [MsgId: MMSG-26659]
在web_url()中Resource属性的解释: Resource - A value indicating whether the URL is a resource:
0 – the URL is not a resource :resource=0 URL为非资源
1 – the URL is a resource :resource=1 URL为资源
从以上日志可以看到,下载的都是web_url()中EXTRARES资源列表里的资源。若将上面的脚本以url_based的方式录制,web_url()这个请求如下
web_url("ntesdoor2_2", "URL=http://entry.mail.163.com/coremail/fcg/ntesdoor2?lightweight=1&verifycookie=1&language=-1&from=web&df=webmail163", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t4.inf", "Mode=HTTP", LAST); web_concurrent_start(NULL); web_url("skin_163blue.css", "URL=http://mimg.127.net/p/js5/5.0.0b1211141530/css/skin_163blue.css", "Resource=1", "RecContentType=text/css", "Referer=http://twebmail.mail.163.com/js5/main.jsp?sid=----", "Snapshot=t5.inf", LAST); web_url("js5pd163.js", "URL=http://mimg.127.net/external/js5pd163.js", "Resource=1", "RecContentType=application/x-javascript", "Referer=http://twebmail.mail.163.com/js5/main.jsp?sid=----------------", "Snapshot=t7.inf", LAST); web_url("js5public163.js", "URL=http://mimg.127.net/external/js5public163.js", "Resource=1", "RecContentType=application/x-javascript", "Referer=http://twebmail.mail.163.com/js5/main.jsp?sid=---------------", "Snapshot=t9.inf", LAST); web_url("p1.js", "URL=http://mimg.127.net/p/js5/5.0.0b1211141530/js/p1.js", "Resource=1", "RecContentType=application/x-javascript", "Referer=http://twebmail.mail.163.com/js5/main.jsp?sid=---------------", "Snapshot=t10.inf", LAST); web_url("p0.js", "URL=http://mimg.127.net/p/js5/5.0.0b1211141530/js/p0.js", "Resource=1", "RecContentType=application/x-javascript", "Referer=http://twebmail.mail.163.com/js5/main.jsp?sid=---------------", "Snapshot=t11.inf", LAST); web_url("163logo.gif", "URL=http://mimg.127.net/logo/163logo.gif", "Resource=1", "RecContentType=image/gif", "Referer=http://twebmail.mail.163.com/js5/main.jsp?sid--------", "Snapshot=t12.inf", LAST); web_url("fix_v3_min.js", "URL=http://mimg.127.net/p/js5/5.0.0b1211141530/js/fix_v3_min.js", "Resource=1", "RecContentType=application/x-javascript", "Referer=http://twebmail.mail.163.com/js5/main.jsp?sid-------------", "Snapshot=t17.inf", LAST); web_concurrent_end(NULL); web_url("base64_compress.css", "URL=http://mimg.127.net/p/js5/5.0.0b1211141530/css/base64_compress.css", "Resource=1", "RecContentType=text/css", "Referer=http://twebmail.mail.163.com/js5/main.jsp?-------", "Snapshot=t6.inf", LAST); web_url("neteasefont-regular.eot", "URL=http://mimg.127.net/p/font/js5/v1/neteasefont-regular.eot", "Resource=1", "RecContentType=application/octet-stream", "Referer=http://twebmail.mail.163.com/js5/main.jsp?------------", "Snapshot=t8.inf", LAST); web_concurrent_start(NULL); web_url("121030_js5jifen_509x289.jpg", "URL=http://mimg.127.net/xm/all/point_club/-------
"RecContentType=image/jpeg", "Referer=http://twebmail.mail.163.com/js5/main.--", "Snapshot=t13.inf", LAST); web_url("top_right.jpg", "URL=http://mimg.127.net/p/js5/5.0.0b1211141530/img/skin_163blue/top_right.jpg", "Resource=1", "RecContentType=image/jpeg", "Referer=http://twebmail.mail.163.com/js5/main.jsp?---
LAST); web_url("t.gif", "URL=http://mimg.127.net/p/t.gif", "Resource=1", "RecContentType=image/gif", "Referer=http://twebmail.mail.163.com/js5/main.jsp?sid=----------------", "Snapshot=t15.inf", LAST); web_url("submit.png", "URL=http://mimg.127.net/p/js5/5.0.0b1211141530/img/wel/submit.png", "Resource=1", "RecContentType=image/png", "Referer=http://twebmail.mail.163.com/js5/main.-----------", "Snapshot=t16.inf", LAST); web_concurrent_end(NULL); web_concurrent_start(NULL); web_url("music.js", "URL=http://mimg.127.net/p/js5/5.0.0b1211141530/js/product/music.js", "Resource=1", "RecContentType=application/x-javascript", "Referer=http://twebmail.mail.163.com/js5/main.jsp?sid=-----------------", "Snapshot=t18.inf", LAST); web_url("bg.png", "URL=http://mimg.127.net/p/js5/5.0.0b1211141530/img/skin_163blue/bg.png", "Resource=1", "RecContentType=image/png", "Referer=http://twebmail.mail.163.com/js5/main.jsp?sid=-------------------", "Snapshot=t19.inf", LAST); web_concurrent_end(NULL);
这样就可以看清,设置了下载D( download non-html resource),下载的资源都是resource=1的url.
这样看来,以HTML-based录制的脚本,提交函数中的resource=0,设置D后,下载的是extrares部分的资源
以URL-based录制的脚本,设置D后,下载的是resource=1 url 中资源
即,用以resource=0标识的url不是资源,是一个必须的请求。用resource=1标识,说明这个url请求的是个资源
2--对发包量的影响--
设置D,会造成发包量增加很多以外,其他选项的设置基本上对发包数量影响不是很大。而且会大量增加TCP的连接数
所以选择D选项要慎重,很耗测试机的资源。
3--TCP连接数的影响--
E是与TCP连接数相关的,因为是模拟一个新的用户,要断开所有连接,建立新的连接。所以选择了E,会增加TCP的连接数
(none什么都没设置)左边为第一次迭代的日志,右边是第二次迭代的日志,有一些不同,但是目前能力有限看不懂,重定向的一些东西.此外第二次迭代的请求的body的部分明显比第一次的要小(tcp/ip协议的基础知识要补充)
web_url("ntesdoor2", "URL=http://entry.mail.163.com/coremail/fcg/ntesdoor2?lightweight=1&verifycookie=1&language=-1&from=web&df=webmail163", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t2.inf", "Mode=HTML", LAST);
A:Simulate browser cache,模拟浏览器缓存后,lr提交的收到body要比什么都不设置要大(日志中显示的应该是收到的响应,请求的长度没有那么大,而且TCP包没有分片)
AB:Cache URLs requiring content(HTMLs)&&Simulate browser cache,这个回放的日志与上面的就有明显的差别了,在第二次迭代时多了retrieving data from cache from ----,在第一迭代的时候保存了cache,第二次迭代取缓存内容(),web_url(“mail.163.com”)返回body是0,他使用了缓存的部分
ABEF:其中E,F选项使每次运行都模拟一个新用户,并且每次跌倒都清除了cache,所有没有retrieving data from cache.并且在Action(38)这部分的日志是一样的,但是第二次迭代的响应body更小一些
ABE:没有设置F,迭代之间没有清理缓存,日志中出现了Retrieving data from cache,web_url("mail.163.com")返回body为0.这个是因为lr没有发送访问mail.163.com这个请求还是什么原因?
到抓到的包里去看一下,这个请求对应的包是GET / HTTP/1.1 里面的内容是request URI:mail.163.com/l.在设置B的抓包文件里这个包只被发送了一次,而在其他抓包文件中都是出现2次(因为迭代了两次)。根据ABE与ABEF设置的区别,可以明确看出,迭代之间清理缓存之间的差别了。设置了B后,对服务器的压力变小了。
E:设置了模拟新用户,在没有设置A时,web_url(“ntestdoor2”)这个请求返回的body字节数较小。
EF:这个与E的日志基本一样,在消息的字节数上也没有什么差别
通过以上实验可以得出以下结论:
1--如不设置浏览器缓存A,两次迭代中body字节数基本相同.如设置了A,第二次迭代中,响应body字节数会小一些
2--若设置了B,第二次迭代时,发包数会略小,有些请求不向服务器发送,使用了lr的缓存
3--设置了EF,清理了lr的缓存后,B的设置就对第二次迭代不起作用了
lr模拟真实浏览器的程度?
清除掉所有缓存
使用ie访问两次mail.163.com(自动登录,没有删除cookies),分析包的情况
清理掉缓存后,使用ie自动登录mail.163.com发包量在1400左右,连接数25个左右,第二次登录发包量在300左右,连接数为13个左右
这样在做压力测试时候,根据不同的业务需求就可以清楚对浏览器进行设置了。
如果想要真实的模拟全新的用户去访问网站,D这个选项就要设置(浏览器的全部设置都要勾选),如果模拟的用户已经浏览过这个网站,那么默认的浏览器设置是比较适合的(ABEF)
备注:在lr和controller中运行的脚本不会改变本地的浏览器缓存文件,lr中回放脚本时,需要缓存文件也不是从本地缓存文件取的,而是在autologinmail163(脚本目录)\data目录下,lr把缓存的东西放在那里。
在C:\Program Files\HP\LoadRunner\bin\vslick\win\vslick\vsdelta\C\Documents and Settings\用户\Local Settings\Temp
这个是lr在C\Documents and Settings\YanFa\Local Settings\Temp建立的一个存放临时文件目录
web_url 中对EXTRARES的补充
EXTRARES中的内容说明载入页面时,还有其他图片或是附属资源需要下载,由于默认的web_url函数或是web_link函数使用HTML Mode,所以无论脚本中是否存在EXTRARES字段,完成函数时都会自动下载HTML对应的所有资源。
实验场景一:
步骤1:使用HTML-based URL only模式登陆www.baidu.con首页
以下是脚本:
web_url("www.baidu.com",
"URL=http://www.baidu.com/",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t1.inf",
"Mode=HTML",
EXTRARES,
"Url=http://s1.bdstatic.com/r/www/cache/static/global/img/icons_e540198d.png", ENDITEM,
"Url=http://s1.bdstatic.com/r/www/cache/static/sug/js/bdsug_e259ada8.js", ENDITEM,
"Url=http://passport.baidu.com/passApi/js/uni_login_wrapper.js?cdnversion=1404797934687&_=1404797934578", ENDITEM,
"Url=/favicon.ico", "Referer=", ENDITEM,
"Url=http://suggestion.baidu.com/su?wd=&zxmode=1&json=1&p=3&sid=5015_1450_7570_5224_6995_7540_7532_7443_6504_6018_7202_7379_6708_7418_7414&cb=jQuery110204499035349637204_1404797934579&_=1404797934580", ENDITEM,
//"Url=http://nsclick.baidu.com/v.gif?pid=201&pj=www&fm=behs&tab=tj_duty&query=&un=&path=http%3A%2F%2Fwww.baidu.com%2F&wd=&rsv_sid=5015_1450_7570_5224_6995_7540_7532_7443_6504_6018_7202_7379_6708_7418_7414&t=1404797984890", ENDITEM,
LAST);
步骤2:然后run time setting 中选择download non-HTML resourse方式回放,并查看回放log
Action.c(12): Found resource "http://www.baidu.com/img/baidu_jgylogo3.gif" in HTML "http://www.baidu.com/" [MsgId: MMSG-26659]
Action.c(12): Found resource "http://www.baidu.com/img/bdlogo.gif" in HTML "http://www.baidu.com/" [MsgId: MMSG-26659]
Action.c(12): Downloading resource "http://s1.bdstatic.com/r/www/cache/static/global/img/icons_e540198d.png" (specified by argument number 10) [MsgId: MMSG-26577]
Action.c(12): Downloading resource "http://s1.bdstatic.com/r/www/cache/static/sug/js/bdsug_e259ada8.js" (specified by argument number 12) [MsgId: MMSG-26577]
Action.c(12): Downloading resource "http://passport.baidu.com/passApi/js/uni_login_wrapper.js?cdnversion=1404797934687&_=1404797934578" (specified by argument number 14) [MsgId: MMSG-26577]
Action.c(12): Downloading resource "http://www.baidu.com/favicon.ico" (specified by argument number 16) [MsgId: MMSG-26577]
Action.c(12): Downloading resource "http://suggestion.baidu.com/su?wd=&zxmode=1&json=1&p=3&sid=5015_1450_7570_5224_6995_7540_7532_7443_6504_6018_7202_7379_6708_7418_7414&cb=jQuery110204499035349637204_1404797934579&_=1404797934580" (specified by argument number 19) [MsgId: MMSG-26577]
Action.c(12): Downloading resource "http://nsclick.baidu.com/v.gif?pid=201&pj=www&fm=behs&tab=tj_duty&query=&un=&path=http%3A%2F%2Fwww.baidu.com%2F&wd=&rsv_sid=5015_1450_7570_5224_6995_7540_7532_7443_6504_6018_7202_7379_6708_7418_7414&t=1404797984890" (specified by argument number 21) [MsgId: MMSG-26577]
Action.c(12): Found resource "http://www.baidu.com/cache/global/img/gs-2.0.gif" in HTML "http://www.baidu.com/" [MsgId: MMSG-26659]
Action.c(12): Found resource "http://s1.bdstatic.com/r/www/cache/static/jquery/jquery-1.10.2.min_f2fb5194.js" in HTML "http://www.baidu.com/" [MsgId: MMSG-26659]
Action.c(12): Found resource "http://s1.bdstatic.com/r/www/cache/static/global/js/all_async_popstate_3c4b1620.js" in HTML "http://www.baidu.com/" [MsgId: MMSG-26659]
Action.c(12): web_url("www.baidu.com") was successful, 109742 body bytes, 4095 header bytes, 47 chunking overhead bytes [MsgId: MMSG-26385]
结论1:回放日志可以看到,下载的资源共有11项,红色6项,绿色5项。其中红色部分与录制的脚本中EXTRARES中的资源一致
步骤3:将脚本中EXTRARES全部注释掉,再次以run time setting 中选择download non-HTML resourse方式回放,并查看回放log
Action.c(12): Found resource "http://www.baidu.com/img/baidu_jgylogo3.gif" in HTML "http://www.baidu.com/" [MsgId: MMSG-26659]
Action.c(12): Found resource "http://www.baidu.com/img/bdlogo.gif" in HTML "http://www.baidu.com/" [MsgId: MMSG-26659]
Action.c(12): Found resource "http://www.baidu.com/cache/global/img/gs-2.0.gif" in HTML "http://www.baidu.com/" [MsgId: MMSG-26659]
Action.c(12): Found resource "http://s1.bdstatic.com/r/www/cache/static/jquery/jquery-1.10.2.min_f2fb5194.js" in HTML "http://www.baidu.com/" [MsgId: MMSG-26659]
Action.c(12): Found resource "http://s1.bdstatic.com/r/www/cache/static/global/js/all_async_popstate_3c4b1620.js" in HTML "http://www.baidu.com/" [MsgId: MMSG-26659]
Action.c(12): web_url("www.baidu.com") was successful, 83482 body bytes, 2262 header bytes, 34 chunking overhead bytes [MsgId: MMSG-26385]
结论2:回放日志中只有步骤2中绿色的资源是被下载的
步骤4:注销对EXTRARES的注释,以run time setting 中不选中download non-HTML resourse方式回放(即不下载资源),并查看回放log
Action.c(12): web_url("www.baidu.com") was successful, 15025 body bytes, 562 header bytes, 13 chunking overhead bytes [MsgId: MMSG-26385]
结论3:没有任何下载资源的记录
场景二:以url-based方式录制登陆www.baidu.com的首页,
步骤1:以download non-HTML回放
Action.c(6): web_url("www.baidu.com") was successful, 15032 body bytes, 562 header bytes, 13 chunking overhead bytes [MsgId: MMSG-26385]
Action.c(15): web_concurrent_start was successful [MsgId: MMSG-26392]
Action.c(17): Registering web_url("jquery-1.10.2.min_f2fb5194.js") was successful [MsgId: MMSG-26390]
Action.c(25): Registering web_url("baidu_jgylogo3.gif") was successful [MsgId: MMSG-26390]
Action.c(33): Registering web_url("bdlogo.gif") was successful [MsgId: MMSG-26390]
Action.c(41): Registering web_url("gs-2.0.gif") was successful [MsgId: MMSG-26390]
Action.c(49): Registering web_url("all_async_popstate_3c4b1620.js") was successful [MsgId: MMSG-26390]
Action.c(57): web_concurrent_end was successful, 68464 body bytes, 1743 header bytes [MsgId: MMSG-26386]
Action.c(61): web_url("icons_e540198d.png") was successful, 16903 body bytes, 332 header bytes [MsgId: MMSG-26386]
Action.c(69): web_concurrent_start was successful [MsgId: MMSG-26392]
Action.c(71): Registering web_url("bdsug_e259ada8.js") was successful [MsgId: MMSG-26390]
Action.c(79): Registering web_url("uni_login_wrapper.js") was successful [MsgId: MMSG-26390]
Action.c(87): Registering web_url("favicon.ico") was successful [MsgId: MMSG-26390]
Action.c(95): Registering web_url("su") was successful [MsgId: MMSG-26390]
Action.c(103): web_concurrent_end was successful, 9380 body bytes, 1424 header bytes [MsgId: MMSG-26386]
结论1:绿色的部分为产生流量的记录,第一个并行提交的部分web_concurrent_start was successful [MsgId: MMSG-26392]与场景一中的EXTRARES的资源一致,第二部分为自动下载的HTML资源,下载的资源量与以HTML-based的download non-HTML回放也基本一致
步骤2:以非download non-HTML方式进行回放
Action.c(6): web_url("www.baidu.com") was successful, 15039 body bytes, 726 header bytes, 13 chunking overhead bytes [MsgId: MMSG-26385]
Action.c(15): web_concurrent_start was successful [MsgId: MMSG-26392]
Action.c(17): Resource "http://s1.bdstatic.com/r/www/cache/static/jquery/jquery-1.10.2.min_f2fb5194.js" not downloaded (resource downloading not requested) [MsgId: MMSG-27299]
Action.c(25): Resource "http://www.baidu.com/img/bdlogo.gif" not downloaded (resource downloading not requested) [MsgId: MMSG-27299]
Action.c(33): Resource "http://www.baidu.com/cache/global/img/gs-2.0.gif" not downloaded (resource downloading not requested) [MsgId: MMSG-27299]
Action.c(41): Resource "http://www.baidu.com/img/baidu_jgylogo3.gif" not downloaded (resource downloading not requested) [MsgId: MMSG-27299]
Action.c(49): Resource "http://s1.bdstatic.com/r/www/cache/static/global/js/all_async_popstate_3c4b1620.js" not downloaded (resource downloading not requested) [MsgId: MMSG-27299]
Action.c(57): web_concurrent_end was successful [MsgId: MMSG-26392]
Action.c(61): Resource "http://s1.bdstatic.com/r/www/cache/static/global/img/icons_e540198d.png" not downloaded (resource downloading not requested) [MsgId: MMSG-27299]
Action.c(69): web_concurrent_start was successful [MsgId: MMSG-26392]
Action.c(71): Resource "http://s1.bdstatic.com/r/www/cache/static/sug/js/bdsug_e259ada8.js" not downloaded (resource downloading not requested) [MsgId: MMSG-27299]
Action.c(79): Resource "http://passport.baidu.com/passApi/js/uni_login_wrapper.js?cdnversion=1404799873328&_=1404799873203" not downloaded (resource downloading not requested) [MsgId: MMSG-27299]
Action.c(87): Resource "http://www.baidu.com/favicon.ico" not downloaded (resource downloading not requested) [MsgId: MMSG-27299]
Action.c(95): Resource "http://suggestion.baidu.com/su?wd=&zxmode=1&json=1&p=3&sid=7574_5229_1460_7571_5223_6995_7539_7532_7442_6505_6018_7202_7134_6888_7384_7414&cb=jQuery110206677635930335499_1404799873204&_=1404799873205" not downloaded (resource downloading not requested) [MsgId: MMSG-27299]
Action.c(103): web_concurrent_end was successful [MsgId: MMSG-26392]
结论2:从日志中可以看出,只有红色的部分URL产生了流量,其他资源其实并没有被下载,没有产生流量,URL,HTML模式以非download non-HTML resource产生的流量也是基本一致的
(url方式是将所有的资源单独用一个web_url提交,所以URL方式录制脚本中web_url数=html方式的EXTRARES+自动下载的资源+主请求)
场景三:
用抓包的方式,查看登录www.baidu.com的交互流程
关于web_url 中对EXTRARES的补充结论如下:
1、 EXTRARES中如果请求的地址和主请求相同不会产生新的流量(这句话意思我不太懂,自己理解的意思就是如果EXTRARES中的请求资源与主请求的url是一样的,就不会产生流量)
2、录制到的EXTRARES不是简单的将图片拆出,而是住请求请求不到的内容
3、错误的EXTRARES会产生额外的请求
4、EXTRARES中的内容说明载入页面时,还有其他图片或是附属资源需要下载,由于默认的web_url函数或是web_link函数使用HTML Mode,所以无论脚本中是否存在EXTRARES字段,完成函数时都会自动下载HTML对应的所有资源。EXTRARES段是一种扩展验证机制,验证这些对象是否存在,如果EXTRARES中的请求并不在返回内,那么回放脚本会比真实情况略微增加带宽的使用
以上结论摘自《性能测试进阶指南》
对比以上4步骤可以与结论做一下对应:
步骤2中红色部分为web_url中的EXTRARES部分,绿色部分为:HTML Mode,所以无论脚本中是否存在EXTRARES字段,完成函数时都会自动下载HTML对应的所有资源,所以当脚本中EXTRARES部分被注释掉,再次回放,日志就只剩绿色的部分了。