【发布时间】:2021-11-03 08:08:36
【问题描述】:
我编写代码发送 POST 请求并等待来自服务器的响应。
我需要测量在服务器上处理信息所需的确切时间(响应时间)。 我注意到当我向服务器发送请求时,使用 放心 的时间比我通过 POSTMAN
得到的时间要长得多所以我的问题是,我怎样才能最准确地测量时间,并接近我通过 POSTMAN 得到的结果
我在网上搜索了几天,没有找到解决办法
提前感谢所有帮助者!!!
编辑
我使用放心的图书馆 而且我有为我执行 POST 操作的功能
public static Response postSubTotal (String var_baseURI, String FileLocation){
RestAssured.baseURI =var_baseURI;
RequestSpecification request = RestAssured.given();
// Add a header stating the Request body is a JSON
request.header("Content-Type", "application/json");
// Add the Json to the body of the request
request.body(BaseJSON.getString(FileLocation));
// Post the request and check the response
Response response = request.post("/Transaction/SubTotal");
return response;
我需要从响应中取出确切的时间。 那么我如何使用过滤器来做到这一点 我需要发送到此函数以从总时间中过滤处理时间,以便 我只剩下响应时间
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
}
【问题讨论】:
-
Postman 提供了一些关于网络和第一个字节的指标。您可以查看文档。
标签: java automation postman rest-assured