Comments (8)
如果想在页面上输出这个总的执行时间,这方式貌似有问题,在next.handle(target, request, response, isHandled)前后记录时间差。差值是在handle之后,页面已经处理完了。
from jboot.
这个之前早就支持了,jboot 中已经输出了整个请求执行的时间。
from jboot.
这个之前早就支持了,jboot 中已经输出了整个请求执行的时间。
你那仅仅输出了调用controller之前到方法invoke后的时间,后面还有render的解析时间。
if (devMode) { long time = System.currentTimeMillis(); try { invocation.invoke(); } finally { JbootActionReporter.report(target, controller, action, invocation, time);
from jboot.
这个之前早就支持了,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.
这个之前早就支持了,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.
这个之前早就支持了,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.
完全同意你上面的前一段,问题是你这段代码是输出take time之后才执行的,还能统计?
from jboot.
完全同意你上面的前一段,问题是你这段代码是输出take time之后才执行的,还能统计?
确实是我理解有问题了,之前的代码并不包含 指令 的消耗时间,刚刚 push 的代码已经添加了相关支持了
from jboot.
Related Issues (20)
- 数据源跟表的映射问题
- dubbo的反序列化漏洞
- 是否能支持Springboot3呢? HOT 1
- Jedis插件不支持IPV6地址
- 手机号码验证缺少最新的199等号段 HOT 2
- 错字受就是你了! (雾 HOT 1
- 如何不启动HTTP服务器的情况下使用数据库? HOT 2
- 关闭Paras和Sql指令输出 HOT 2
- 在插件的类加载器环境无法读取properties HOT 1
- httpPost 方法的参数如果是多层的对象有bug
- Axios跨域调用 预检使用OPTIONS报错 HOT 1
- 是否有支持nacos的计划? HOT 2
- xxl-job-executor-sample-jboot如何设置jboot参数 HOT 1
- 生成代码报错 HOT 1
- 请更新 Dubbo 坐标 HOT 1
- 升级到3.1.x之后,Dubbo配置无效 HOT 1
- JbootInvocation 没有重写Invocation setArg getArg 倒致参数不能向下传递 HOT 1
- jboot代码生成器优化建议 HOT 1
- 关于JbootGatewayConfig 方法添加支持需求 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jboot.