LoadRunner脚本设计之请求并发的使用

2016-07-05  秦天 

有这样一种场景,当点击某一个按钮时,会同时发送出多个请求到服务器,这样的应用怎样设计打压脚本更符合应用场景呢?

查了下资料。LoadRunner中的web_concurrent函数可以模拟这种情况。

具体打压脚本设计如下:

将想要同时发送的请求包含在web_concurrent_start(NULL)和web_concurrent_end(NULL)函数之间,这样LoadRunner在执行到web_concurrent_start时,后续的脚本都不会立即被执行,直到web_concurrent_end出现。才把这中间的所有的脚本一起执行。

具体脚本设计如下:


vuser_init()
{
        web_url("vdAction.do",
                "URL=http://www.a.com",
                "Resource=0",
                "RecContentType=text/html",
                "Referer=",
                "Snapshot=t1.inf",
                "Mode=HTTP",
                LAST);

        web_concurrent_start(NULL);

        web_url("vd.jpg",
                "URL=http://www.b.com/images/vd.jpg",
                "Resource=1",
                "RecContentType=image/jpeg",
                "Referer=http://www.b.com/vd/vdAction.do?opAction=vd&id=112",
                LAST);

        web_url("adv.gif",
                "URL=http://ip:8090/world/images/adv.gif",
                "Resource=1",
                "RecContentType=image/gif",
                "Referer=http://218.108.247.148/WCFT/vd/vdAction.do?opAction=vd&id=112",
                LAST);

        web_url("blank.gif",
                "URL=http://www.b.com/images/blank.gif",
                "Resource=1",
                "RecContentType=image/gif",
                "Referer=http://218.108.247.148/WCFT/vd/vdAction.do?opAction=vd&id=112",
                LAST);

        web_concurrent_end(NULL);

        return 0;
}

384°/3845 人阅读/0 条评论 发表评论

登录 后发表评论