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

纯稀饭 · 2017年08月20日 · 最后由 纯稀饭 回复于 2017年08月21日 · 1416 次阅读

录制接口如下

.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 条回复 时间 点赞
纯稀饭 关闭了讨论 08月21日 11:13

认真翻了翻文档
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 测出来的性能差别还是挺明显的。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册