在我的阀门中,我得到了我的 http 查询的执行时间:
public void invoke(Request request, Response response)
throws IOException, ServletException {
long t1 = System.currentTimeMillis();
getNext().invoke(request, response);
long t2 = System.currentTimeMillis();
long time = t2 - t1;
...
}
我怀疑我这样得到的时间,不仅给了我服务器端的执行时间,还给了我网络时间?是否可以 ?
(因为根据发出请求的客户端,测量的平均时间与一个 IP 不同,我有 70 毫秒的平均时间和另一个 270 毫秒的 IP)
我在过滤器中编写了完全相同的代码:
long before = System.currentTimeMillis();
chain.doFilter(request, response);
long after = System.currentTimeMillis();
,但在我的测试中,阀门和过滤器中的执行时间是相同的......
我对只获取我的 servlet 的执行时间更感兴趣。但如果我也能得到发送最后一个字节的时间,我会感兴趣的。
非常感谢您向我澄清有关阀门和过滤器的知识。