Giter VIP home page Giter VIP logo

Comments (8)

superbase-zz avatar superbase-zz commented on May 25, 2024

如果想在页面上输出这个总的执行时间,这方式貌似有问题,在next.handle(target, request, response, isHandled)前后记录时间差。差值是在handle之后,页面已经处理完了。

from jboot.

yangfuhai avatar yangfuhai commented on May 25, 2024

这个之前早就支持了,jboot 中已经输出了整个请求执行的时间。

from jboot.

superbase-zz avatar superbase-zz commented on May 25, 2024

这个之前早就支持了,jboot 中已经输出了整个请求执行的时间。

你那仅仅输出了调用controller之前到方法invoke后的时间,后面还有render的解析时间。
if (devMode) { long time = System.currentTimeMillis(); try { invocation.invoke(); } finally { JbootActionReporter.report(target, controller, action, invocation, time);

from jboot.

yangfuhai avatar yangfuhai commented on May 25, 2024

这个之前早就支持了,jboot 中已经输出了整个请求执行的时间。

你那仅仅输出了调用controller之前到方法invoke后的时间,后面还有render的解析时间。
if (devMode) { long time = System.currentTimeMillis(); try { invocation.invoke(); } finally { JbootActionReporter.report(target, controller, action, invocation, time);

开发工具中输出的时间就是整个 Controller执行的时间 + 所有 html 质量渲染的时间 + 输出到网络的时间。如果您这边确定要知道 每个方法的时间,建议引入 skywalking 之类的第三方 APM 框架才是正确的选择。

from jboot.

superbase-zz avatar superbase-zz commented on May 25, 2024

这个之前早就支持了,jboot 中已经输出了整个请求执行的时间。

你那仅仅输出了调用controller之前到方法invoke后的时间,后面还有render的解析时间。
if (devMode) { long time = System.currentTimeMillis(); try { invocation.invoke(); } finally { JbootActionReporter.report(target, controller, action, invocation, time);

开发工具中输出的时间就是整个 Controller执行的时间 + 所有 html 质量渲染的时间 + 输出到网络的时间。如果您这边确定要知道 每个方法的时间,建议引入 skywalking 之类的第三方 APM 框架才是正确的选择。

实际情况并非如此,理由如下:
if (devMode) {
//计时开始
long time = System.currentTimeMillis();
try {
invocation.invoke();
} finally {
JbootActionReporter.report(target, controller, action, invocation, time);
//sb.append("----------------------------------- taked " + (System.currentTimeMillis() - time) + " ms ------
//上一句中仅仅输出了controller里的invoke后的时间。,然而看看JbootActionHandler后面的部分,
}
} else {
invocation.invoke();
}

        **Render render = controller.getRender();**

render.setContext(request, response, action.getViewPath()).render();
如果页面里面使用了自定义函数或Directive等内容,则消耗的时间完全没有包含在内。
我现在作法就是,定义一个handler,进入时封装,并将guava的Stopwatch初始后存在Handler的ThreadLocal中。
一直到handler的next.handle(target, request, response, isHandled); 结束,才输出总共的耗时。
因为我在controller中几乎没有什么业务代码,仅仅接收几个参数,主要业务都变成了多个Directive的调用,整个过程最后输出的耗时和Jboot中 taked xx ms的时间相差非常大。

from jboot.

yangfuhai avatar yangfuhai commented on May 25, 2024

这个之前早就支持了,jboot 中已经输出了整个请求执行的时间。

你那仅仅输出了调用controller之前到方法invoke后的时间,后面还有render的解析时间。
if (devMode) { long time = System.currentTimeMillis(); try { invocation.invoke(); } finally { JbootActionReporter.report(target, controller, action, invocation, time);

开发工具中输出的时间就是整个 Controller执行的时间 + 所有 html 质量渲染的时间 + 输出到网络的时间。如果您这边确定要知道 每个方法的时间,建议引入 skywalking 之类的第三方 APM 框架才是正确的选择。

实际情况并非如此,理由如下:
if (devMode) {
//计时开始
long time = System.currentTimeMillis();
try {
invocation.invoke();
} finally {
JbootActionReporter.report(target, controller, action, invocation, time);
//sb.append("----------------------------------- taked " + (System.currentTimeMillis() - time) + " ms ------
//上一句中仅仅输出了controller里的invoke后的时间。,然而看看JbootActionHandler后面的部分,
}
} else {
invocation.invoke();
}

        **Render render = controller.getRender();**

render.setContext(request, response, action.getViewPath()).render();
如果页面里面使用了自定义函数或Directive等内容,则消耗的时间完全没有包含在内。
我现在作法就是,定义一个handler,进入时封装,并将guava的Stopwatch初始后存在Handler的ThreadLocal中。
一直到handler的next.handle(target, request, response, isHandled); 结束,才输出总共的耗时。
因为我在controller中几乎没有什么业务代码,仅仅接收几个参数,主要业务都变成了多个Directive的调用,整个过程最后输出的耗时和Jboot中 taked xx ms的时间相差非常大。

render.setContext(request, response, action.getViewPath()).render(); 这行代码,就已经包含了指令(Directive)、和自定义函数的执行时间了。你可以自己测试下看,比如自定义一个指令,让这个指令里休眠 几秒钟。然后看看结果。

from jboot.

superbase-zz avatar superbase-zz commented on May 25, 2024

完全同意你上面的前一段,问题是你这段代码是输出take time之后才执行的,还能统计?

from jboot.

yangfuhai avatar yangfuhai commented on May 25, 2024

完全同意你上面的前一段,问题是你这段代码是输出take time之后才执行的,还能统计?

确实是我理解有问题了,之前的代码并不包含 指令 的消耗时间,刚刚 push 的代码已经添加了相关支持了

from jboot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.