loadrunner---<三>---菜鳥對Browser Emulation的思考

以前在一個web是項目作性能測試,發現controller中場景運行的時候,mrdv.exe內存所耗內存在不斷增長,最後報錯中止了javascript

not enough memory for new buffer in LrwSrvNetTaskItem::AllocSrvNetBuf---沒有內存了css

而後打開analysis中的監控本機的資源圖,測試機的內存在不斷的較小,一直減少到提示錯誤,最後內存的 剩餘量不記得了。在場景運行的過程當中,從任務管理器看,內存也是不斷減少。聽測試羣中的人說這種現象叫:腳本吃內存了html

測試的內容是開發部門提供的http接口,不是錄製的腳本,就是到數據庫中查詢,而後對返回狀態作判斷,判斷時候。不須要考慮申請內存再釋放內存的問題,腳本中除了事務,檢查點沒有添加其餘的函數,因此,能夠確定不是腳本的問題(此外,從controller中的vuser的show vuser log查找錯誤出現的位置,有兩處,一處是空白行,一處是提交的請求)java

在網上搜,發現是Browser Emulation設置的問題,run-time-setting裏面的設置有問題jquery

後來將Browser Emulation的選項都禁止,mrdv佔用的內存基本不變了,再也不增長。web

備註:可是測試了一下登錄mail.163.com中Browser Emulation設置,設置了下載非資源文件的選項的狀況下,內存佔用比較大,可是並無出現內存佔用量不斷增長的現象(測試時間約爲20分鐘),這個問題有待考慮。。。數據庫

下面總結一下Browser Emulationjson

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的補充結論以下:

一、 EXTRARES中若是請求的地址和主請求相同不會產生新的流量(這句話意思我不太懂,本身理解的意思就是若是EXTRARES中的請求資源與主請求的url是同樣的,就不會產生流量)

二、錄製到的EXTRARES不是簡單的將圖片拆出,而是住請求請求不到的內容

三、錯誤的EXTRARES會產生額外的請求

四、EXTRARES中的內容說明載入頁面時,還有其餘圖片或是附屬資源須要下載,因爲默認的web_url函數或是web_link函數使用HTML Mode,因此不管腳本中是否存在EXTRARES字段,完成函數時都會自動下載HTML對應的全部資源。EXTRARES段是一種擴展驗證機制,驗證這些對象是否存在,若是EXTRARES中的請求並不在返回內,那麼回放腳本會比真實狀況略微增長帶寬的使用

以上結論摘自《性能測試進階指南》

對比以上4步驟能夠與結論作一下對應:

步驟2中紅色部分爲web_url中的EXTRARES部分,綠色部分爲:HTML Mode,因此不管腳本中是否存在EXTRARES字段,完成函數時都會自動下載HTML對應的全部資源,因此當腳本中EXTRARES部分被註釋掉,再次回放,日誌就只剩綠色的部分了。

相關文章
相關標籤/搜索