新手区 gatling 录制的 scala 脚本里.resources (http ("request_1").....) 代表什么含义呢?

纯稀饭 · August 20, 2017 · Last by 纯稀饭 replied at August 21, 2017 · 905 hits

录制接口如下

.exec(http("request_0")
.post("/dologin.json")
.headers(headers_0)
.formParam("userForm.email", "xxxxxxx")
.formParam("userForm.password", "xxxxxx")
.resources(
http("request_2")
.get("/")
.headers(headers_2),
http("request_5")
.post("/ajax/websiteProfile/online.json")
.headers(headers_5),
http("request_6")
.post("/user/loginuser.json")
.headers(headers_5),
http("request_7")
.post("/islogin.json")
.headers(headers_5),
http("request_8")
.post("/shopCart/ajax/shopcartnums.json")
.headers(headers_0)
.formParam("type", "1"),
http("request_9")
.post("/letter/queryUnReadLetter.json")
.headers(headers_5),
http("request_10")
.post("/front/ajax/course.json")
.headers(headers_10)
.formParam("subjectId", "0"),
http("request_11")
.post("/ajax/subject.json")
.headers(headers_11),
http("request_12")
.post("/front/ajax/article/getImportantArtile.json")
.headers(headers_5),
http("request_13")
.post("/ajax/subject/course.json")
.headers(headers_10)
.formParam("subjectId", "260")))

因为单测dologin接口的性能还ok,但是录制登陆场景走的是如上请求,并发不到多少就挂了,
没有理解.resources(http("request_1").....)的形式对性能有所影响,请大神指教。

共收到 1 条回复 时间 点赞

认真翻了翻文档
http://gatling.io/docs/current/http/http_request/
Resources
Gatling allow to fetch resources in parallel in order to emulate the behavior of a real web browser.
At the request level you can use the resources(res: AbstractHttpRequestBuilder[_]*) method.

For example:

http("Getting issues")
.get("https://www.github.com/gatling/gatling/issues")
.resources(
http("api.js").get("https://collector-cdn.github.com/assets/api.js"),
http("ga.js").get("https://ssl.google-analytics.com/ga.js")
)
Response chunks discarding

允许并行的获取资源,以模仿真正的浏览器行为。

如上功能点,相比之下和jmeter测出来的性能差别还是挺明显的。

纯稀饭 关闭了讨论 21 Aug 11:13
需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up