放心的响应时间
response time in restassured
我已使用 restassured .time() 方法成功捕获 api 响应时间,但我注意到 restassured 返回的响应时间略高于使用 postman 或 soapui 发送的相同请求。
我到处查看为什么 restassured 花费的时间太长但没有找到任何答案,我还研究了如何减少 restassured 开销的想法,这可能是原因,但也没有成功找到它。
请任何建议可能有助于找到为什么 restassured 的响应时间比其他工具更长
这是我放心的电话,我尝试了所有时间功能来比较放心
Response Response = given().contentType(MediaType.TEXT_XML).accept(MediaType.TEXT_XML).body(content).log().all()
.when().post("https://myurl.com").then().log().all()
.extract().response();
logger.info(Response.getTime());
logger.info(Response.getTimeIn(TimeUnit.SECONDS));
logger.info(Response.time());
logger.info(Response.timeIn(TimeUnit.MILLISECONDS));
如 docs the value is not precise, especially when the JVM is cold. You should regard the time measurement as an approximation rather than fact. For example it can be useful to track statistics (on a CI server) over longer periods of time to find deviations such as sudden spikes related to a specific commit. The reason why you should not regard this as a precise measurement is because REST Assured's response time measurement includes a lot of processing such JVM/Groovy class load times. You should probably using something like JMH 所示,如果您真的想获得适当的基准测试。
我已使用 restassured .time() 方法成功捕获 api 响应时间,但我注意到 restassured 返回的响应时间略高于使用 postman 或 soapui 发送的相同请求。 我到处查看为什么 restassured 花费的时间太长但没有找到任何答案,我还研究了如何减少 restassured 开销的想法,这可能是原因,但也没有成功找到它。 请任何建议可能有助于找到为什么 restassured 的响应时间比其他工具更长
这是我放心的电话,我尝试了所有时间功能来比较放心
Response Response = given().contentType(MediaType.TEXT_XML).accept(MediaType.TEXT_XML).body(content).log().all()
.when().post("https://myurl.com").then().log().all()
.extract().response();
logger.info(Response.getTime());
logger.info(Response.getTimeIn(TimeUnit.SECONDS));
logger.info(Response.time());
logger.info(Response.timeIn(TimeUnit.MILLISECONDS));
如 docs the value is not precise, especially when the JVM is cold. You should regard the time measurement as an approximation rather than fact. For example it can be useful to track statistics (on a CI server) over longer periods of time to find deviations such as sudden spikes related to a specific commit. The reason why you should not regard this as a precise measurement is because REST Assured's response time measurement includes a lot of processing such JVM/Groovy class load times. You should probably using something like JMH 所示,如果您真的想获得适当的基准测试。