Browser Emulation Loadrunner in-depth understanding of

One: the basics

Loadrunner the use of, for the browser in Run-time Settings emulation setting is relatively easy to produce local confusing. Here we combine the sniffer to look at the specific purpose of each option, and the impact on the test.

                                              Browser Emulation 图

1-- What is browser cache? -

 In simple terms, your browser's cache is - use the browser to access the page, the browser will be some pages of text, images, saved to a local file. Then, again using a browser to access the web, previously stored (cached) text and pictures will not be re-downloaded, but rather stored in the local resource.

Browser Emulation is used to set the script playback time, lr simulate browser caching strategy

Cache of things in general are on the C: \ Documents \ Local Settings under Temporary Internet Files and Settings User \ \. You can go open the facade are these - documents and images, and are you ever visited interface information

2 - Browser Emulation Option Description -

Detailed See: http://www.rosoo.net/a/201011/10401.html

http://hi.baidu.com/c1425/item/0f4af76fc4f3a20ca1cf0f9d

The above connection settings for the browser, explained well, I tried various settings for the Browser Emulation, than to get caught in the script playback time is substantially correct.

For convenience of description, we agreed with:
A Representative Simulate Browser Cache
B representative of the Cache URLs Requiring Content (HTMLs)
C representative of the Check for newer versions of Stored Pages Every Visit to The Page
D representative of the Download non-the HTML Resources
E Representative Simulate a new user on iteratioin the each
F on behalf of Clear cache on each iteration

Attach help Chinese documents on Browser Emulation

 

II: Case and Tools

1.  Test Case:

Open the Web page twice, compare different Browser Emulation settings loadrunner behavior, the script follows.

Action()
{
web_url("www.primeton.com",
"URL=http://www.primeton.com/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t2.inf",
"Mode=HTML",
LAST);

web_url("www.primeton.com",
"URL=http://www.primeton.com/",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t2.inf",
"Mode=HTML",
LAST);

return 0;
}

 

2. sniffer工具

开源工具:Wireshark(前身是ethereal)(www.wireshark.org)

三:测试过程

为了方便描述,我们约定用:

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

首先设置Run Logic中的iteration为2。让Action运行两次,看看循环运行脚本两次,数据包和连接数的变化。

1. 去掉所有选项

结果:共获取数据包95个,建立连接1个(红色标识),断开连接1个(蓝色标识)

No.     Time        Source            Destination       Protocol Info
1 0.000000 192.168.1.61 203.81.29.137 TCP 13835 > http [SYN] Seq=0 Len=0 MSS=1460 WS=2
2 0.036053 203.81.29.137 192.168.1.61 TCP http > 13835 [SYN, ACK] Seq=0 Ack=1 Win=17280 Len=0 MSS=1440 WS=0
92 1.415887 192.168.1.61 203.81.29.137 TCP 13835 > http [FIN, ACK] Seq=817 Ack=71762 Win=257760 Len=0
94 1.449960 203.81.29.137 192.168.1.61 TCP http > 13835 [FIN, ACK] Seq=71762 Ack=818 Win=16464 Len=0

 

在这种情况下,数据包非常少(没有选择下载资源文件入css,js,gif等),而且你可以看到,打开4次首页,只建立了一个tcp连接。

这时,你即使选择A,发现数据包的数量量页没有变化,因为cache主要还是针对资源文件

2. 选择E(F)

结果:共获取数据包102个,建立连接2个(红色标识),断开连接2个(蓝色标识)

No.     Time        Source            Destination       Protocol Info
1 0.000000 192.168.1.61 203.81.29.137 TCP 13886 > http [SYN] Seq=0 Len=0 MSS=1460 WS=2
2 0.037013 203.81.29.137 192.168.1.61 TCP http > 13886 [SYN, ACK] Seq=0 Ack=1 Win=17280 Len=0 MSS=1440 WS=0
48 0.618117 192.168.1.61 203.81.29.137 TCP 13886 > http [FIN, ACK] Seq=409 Ack=35882 Win=257760 Len=0
49 0.644106 192.168.1.61 203.81.29.137 TCP 13887 > http [SYN] Seq=0 Len=0 MSS=1460 WS=2
51 0.651919 203.81.29.137 192.168.1.61 TCP http > 13886 [FIN, ACK] Seq=35882 Ack=410 Win=16872 Len=0
53 0.676377 203.81.29.137 192.168.1.61 TCP http > 13887 [SYN, ACK] Seq=0 Ack=1 Win=17280 Len=0 MSS=1440 WS=0
99 1.310379 192.168.1.61 203.81.29.137 TCP 13887 > http [FIN, ACK] Seq=409 Ack=35882 Win=257760 Len=0
101 1.347949 203.81.29.137 192.168.1.61 TCP http > 13887 [FIN, ACK] Seq=35882 Ack=410 Win=16872 Len=0

在这种情况下,数据包非常少(没有选择下载资源文件入css,js,gif等),对比第一种情况,你会发现它建立了两个连接,这就是E的作用,它对于每次迭代都当成一个新的用户,需要重新建立连接。

3. 选择DE(F)

结果:共获取数据包1782个,建立连接6个(红色标识),断开连接6个(蓝色标识)

No.     Time        Source            Destination       Protocol Info
1 0.000000 192.168.1.61 203.81.29.137 TCP 14016 > http [SYN] Seq=0 Len=0 MSS=1460 WS=2
2 0.037911 203.81.29.137 192.168.1.61 TCP http > 14016 [SYN, ACK] Seq=0 Ack=1 Win=17280 Len=0 MSS=1440 WS=0
6 0.107432 192.168.1.61 203.81.29.137 TCP 14017 > http [SYN] Seq=0 Len=0 MSS=1460 WS=2
9 0.141816 203.81.29.137 192.168.1.61 TCP http > 14017 [SYN, ACK] Seq=0 Ack=1 Win=17280 Len=0 MSS=1440 WS=0
426 3.334889 192.168.1.61 203.81.29.137 TCP 14017 > http [FIN, ACK] Seq=1852 Ack=150284 Win=257484 Len=0
428 3.372253 203.81.29.137 192.168.1.61 TCP http > 14017 [FIN, ACK] Seq=150284 Ack=1853 Win=16998 Len=0
448 4.395488 192.168.1.61 203.81.29.137 TCP 14020 > http [SYN] Seq=0 Len=0 MSS=1460 WS=2
457 4.439604 203.81.29.137 192.168.1.61 TCP http > 14020 [SYN, ACK] Seq=0 Ack=1 Win=17280 Len=0 MSS=1440 WS=0
859 7.593610 192.168.1.61 203.81.29.137 TCP 14016 > http [FIN, ACK] Seq=2849 Ack=377404 Win=257484 Len=0
870 7.659680 203.81.29.137 192.168.1.61 TCP http > 14016 [FIN, ACK] Seq=377404 Ack=2850 Win=15935 Len=0
888 8.511308 192.168.1.61 203.81.29.137 TCP 14020 > http [FIN, ACK] Seq=1602 Ack=208150 Win=257760 Len=0
890 8.549451 203.81.29.137 192.168.1.61 TCP http > 14020 [FIN, ACK] Seq=208150 Ack=1603 Win=17280 Len=0
892 8.566246 192.168.1.61 203.81.29.137 TCP 14022 > http [SYN] Seq=0 Len=0 MSS=1460 WS=2
893 8.601893 203.81.29.137 192.168.1.61 TCP http > 14022 [SYN, ACK] Seq=0 Ack=1 Win=17280 Len=0 MSS=1440 WS=0
899 8.702628 192.168.1.61 203.81.29.137 TCP 14023 > http [SYN] Seq=0 Len=0 MSS=1460 WS=2
904 8.741807 203.81.29.137 192.168.1.61 TCP http > 14023 [SYN, ACK] Seq=0 Ack=1 Win=17280 Len=0 MSS=1440 WS=0
1298 11.809456 192.168.1.61 203.81.29.137 TCP 14022 > http [FIN, ACK] Seq=1550 Ack=159770 Win=257484 Len=0
1310 11.878665 203.81.29.137 192.168.1.61 TCP http > 14022 [FIN, ACK] Seq=159770 Ack=1551 Win=17280 Len=0
1341 12.771707 192.168.1.61 203.81.29.137 TCP 14026 > http [SYN] Seq=0 Len=0 MSS=1460 WS=2
1348 12.813950 203.81.29.137 192.168.1.61 TCP http > 14026 [SYN, ACK] Seq=0 Ack=1 Win=17280 Len=0 MSS=1440 WS=0
1759 16.032952 192.168.1.61 203.81.29.137 TCP 14023 > http [FIN, ACK] Seq=3151 Ack=367918 Win=257484 Len=0
1761 16.068296 203.81.29.137 192.168.1.61 TCP http > 14023 [FIN, ACK] Seq=367918 Ack=3152 Win=17280 Len=0
1779 16.983042 192.168.1.61 203.81.29.137 TCP 14026 > http [FIN, ACK] Seq=1602 Ack=208150 Win=257760 Len=0
1781 17.016836 203.81.29.137 192.168.1.61 TCP http > 14026 [FIN, ACK] Seq=208150 Ack=1603 Win=17280 Len=0

 

在这种情况下,数据包的数量非常大,连接也很多,由于没有cache功能,每次打开页面都需要重新下载所有的资源文件。

4. 选择ADE

结果:共获取数据包525个,建立连接3个,断开连接3个(不再标识了,syn即为连接请求,fin即为断开请求)

No.     Time        Source            Destination       Protocol Info
1 0.000000 192.168.1.61 203.81.29.137 TCP 14189 > http [SYN] Seq=0 Len=0 MSS=1460 WS=2
2 0.033657 203.81.29.137 192.168.1.61 TCP http > 14189 [SYN, ACK] Seq=0 Ack=1 Win=17280 Len=0 MSS=1440 WS=0
6 0.100636 192.168.1.61 203.81.29.137 TCP 14190 > http [SYN] Seq=0 Len=0 MSS=1460 WS=2
9 0.133703 203.81.29.137 192.168.1.61 TCP http > 14190 [SYN, ACK] Seq=0 Ack=1 Win=17280 Len=0 MSS=1440 WS=0
429 3.383748 192.168.1.61 203.81.29.137 TCP 14190 > http [FIN, ACK] Seq=1852 Ack=150284 Win=257484 Len=0
431 3.418556 203.81.29.137 192.168.1.61 TCP http > 14190 [FIN, ACK] Seq=150284 Ack=1853 Win=16998 Len=0
471 4.352071 192.168.1.61 203.81.29.137 TCP 14189 > http [FIN, ACK] Seq=1504 Ack=235576 Win=257760 Len=0
472 4.380312 192.168.1.61 203.81.29.137 TCP 14192 > http [SYN] Seq=0 Len=0 MSS=1460 WS=2
474 4.389778 203.81.29.137 192.168.1.61 TCP http > 14189 [FIN, ACK] Seq=235576 Ack=1505 Win=17280 Len=0
476 4.413220 203.81.29.137 192.168.1.61 TCP http > 14192 [SYN, ACK] Seq=0 Ack=1 Win=17280 Len=0 MSS=1440 WS=0
522 5.078068 192.168.1.61 203.81.29.137 TCP 14192 > http [FIN, ACK] Seq=409 Ack=35882 Win=257760 Len=0
524 5.115099 203.81.29.137 192.168.1.61 TCP http > 14192 [FIN, ACK] Seq=35882 Ack=410 Win=16872 Len=0

 

在这种情况下,cache发挥作用,数据包对比第三种情况大大减少,几乎等于打开一次首页的数据量(449个数据包),只有第一次打开页面需要完整下载页面(包括资源文件),后面的三次打开页面都只要下载HTML页面(不包括资源文件)。

 

5. 选择ADEF

选择F之后我们看看结果:共获取数据包942个,建立连接4个,断开连接4个

No.     Time        Source            Destination       Protocol Info
1 0.000000 192.168.1.61 203.81.29.137 TCP 14292 > http [SYN] Seq=0 Len=0 MSS=1460 WS=2
2 0.034524 203.81.29.137 192.168.1.61 TCP http > 14292 [SYN, ACK] Seq=0 Ack=1 Win=17280 Len=0 MSS=1440 WS=0
6 0.102314 192.168.1.61 203.81.29.137 TCP 14294 > http [SYN] Seq=0 Len=0 MSS=1460 WS=2
9 0.139752 203.81.29.137 192.168.1.61 TCP http > 14294 [SYN, ACK] Seq=0 Ack=1 Win=17280 Len=0 MSS=1440 WS=0
426 3.791111 192.168.1.61 203.81.29.137 TCP 14294 > http [FIN, ACK] Seq=1852 Ack=150284 Win=257484 Len=0
428 3.824970 203.81.29.137 192.168.1.61 TCP http > 14294 [FIN, ACK] Seq=150284 Ack=1853 Win=16998 Len=0
468 6.213276 192.168.1.61 203.81.29.137 TCP 14292 > http [FIN, ACK] Seq=1504 Ack=235576 Win=257760 Len=0
469 6.244052 192.168.1.61 203.81.29.137 TCP 14297 > http [SYN] Seq=0 Len=0 MSS=1460 WS=2
471 6.249564 203.81.29.137 192.168.1.61 TCP http > 14292 [FIN, ACK] Seq=235576 Ack=1505 Win=17280 Len=0
473 6.279647 203.81.29.137 192.168.1.61 TCP http > 14297 [SYN, ACK] Seq=0 Ack=1 Win=17280 Len=0 MSS=1440 WS=0
479 6.374967 192.168.1.61 203.81.29.137 TCP 14298 > http [SYN] Seq=0 Len=0 MSS=1460 WS=2
484 6.419597 203.81.29.137 192.168.1.61 TCP http > 14298 [SYN, ACK] Seq=0 Ack=1 Win=17280 Len=0 MSS=1440 WS=0
897 9.858493 192.168.1.61 203.81.29.137 TCP 14297 > http [FIN, ACK] Seq=1550 Ack=159770 Win=257484 Len=0
899 9.895188 203.81.29.137 192.168.1.61 TCP http > 14297 [FIN, ACK] Seq=159770 Ack=1551 Win=17280 Len=0
939 12.840029 192.168.1.61 203.81.29.137 TCP 14298 > http [FIN, ACK] Seq=1806 Ack=226090 Win=257760 Len=0
941 12.876120 203.81.29.137 192.168.1.61 TCP http > 14298 [FIN, ACK] Seq=226090 Ack=1807 Win=17076 Len=0

在这种情况下,由于选择了F,在迭代的时候清除了cache,所以每次迭代都需要重新下载资源文件。数据包差不多等于第三种情况的一半,约等于打开两次首页的数据量(449×2个数据包)。

6. 关于BC选项

C的解释(Check for newer versions of stored pages every visit to the page

C比较容易理解,类似IE设置中的每次检查,如果不设置C,LR对于已经cache的文件就不会重新向服务器请求,如果选择C,你就可以在数据包中发现很多304信息。

B的解释(Cache URLs requiring content(HTMLs)

LR对于资源文件的cache并不会真正cache在内存中或者在磁盘上,这个选项表示:对于一些需要用到的关联,校验,页面解析内容真正cache在内存中,减少客户端的重复工作。

当然如果你想把GIF也cache到内存中,你可以在Advanced中设置,选择Specify URL requiring content in addition to HTML pages,加入条目image/gif,并勾选。当Vuser运行的时候,你可以对比一下mmdrv.exe进程的内存消耗(内存占用会更多)。

四: 结论

通过上面的测试分析,我们大概知道了每个选项的真正含义,你需要根据你的测试目的来选择合适的设置:

1、 对于一个具体的应用测试,对于前端Web Server不可忽略,缺省设置非常合适,不需要调整(有时候需要考虑把C选上)

注意:很多人在录制脚本的时候,习惯把登入操作放到vuser_init中,这时候缺省设置可能会抛错,建议把这类的操作都放入到action中

2、 如果你更关注后端应用服务器的性能或者说做一些架构的验证分析,那你缺省设置对于你来说就不合适了,你需要选择取消所有的设置项。

当然你也可以根据自己的具体情况做不同调整,但是一定要真正理解这些选项的具体含义才能做到不犯错误

Guess you like

Origin www.cnblogs.com/zwh-Seeking/p/11775847.html