gpt4 book ai didi

javascript - 如何在 IE 调试控制台中显示 servlet 运行时间?

转载 作者:行者123 更新时间:2023-11-28 17:57:29 25 4
gpt4 key购买 nike

我有如下 JSP 代码,我可以检查 javascript 代码的运行时间,但无法检查 servlet 进程的运行时间,runTime 始终为 0,我该怎么办?

<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="java.util.List"%>
<%@ page import="java.util.ArrayList"%>
<%
long startTime = System.currentTimeMillis();
MyForm myForm = (MyForm) request.getAttribute(ACTION_FORM_KEY);
if(myForm == null) {
myForm = new PsiSearchForm();
}

List<Object> myList = myForm.getMyList();
if(myList == null) {
myList = new ArrayList<Object>();
}
long endTime = System.currentTimeMillis();
long runTime = endTime - startTime;
%>
<html>
...
</form>
</body>
<script language="JavaScript" type="text/JavaScript">
console.time('my_form.jsp');
// javascript process
console.timeEnd('my_form.jsp');
console.log("Select My List time: " + <%=runTime%>);
</script>
</html>

最佳答案

尝试使用System.nanoTime();

来自Oracle

   long startTime = System.nanoTime();
// ... the code being measured ...
long estimatedTime = System.nanoTime() - startTime;

关于javascript - 如何在 IE 调试控制台中显示 servlet 运行时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44191845/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com