-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
新增完整执行时间统计的建议 #91
Comments
如果想在页面上输出这个总的执行时间,这方式貌似有问题,在next.handle(target, request, response, isHandled)前后记录时间差。差值是在handle之后,页面已经处理完了。 |
这个之前早就支持了,jboot 中已经输出了整个请求执行的时间。 |
你那仅仅输出了调用controller之前到方法invoke后的时间,后面还有render的解析时间。 |
开发工具中输出的时间就是整个 Controller执行的时间 + 所有 html 质量渲染的时间 + 输出到网络的时间。如果您这边确定要知道 每个方法的时间,建议引入 skywalking 之类的第三方 APM 框架才是正确的选择。 |
实际情况并非如此,理由如下:
render.setContext(request, response, action.getViewPath()).render(); |
|
完全同意你上面的前一段,问题是你这段代码是输出take time之后才执行的,还能统计? |
确实是我理解有问题了,之前的代码并不包含 指令 的消耗时间,刚刚 push 的代码已经添加了相关支持了 |
sql输出执行时间是个很不错的功能,弥补性能调优中代码中执行SQL代码段大量存在计算耗时的代码,非常实现。
在web性能调优中,大致需求如下:
1,输出整个页面从用户进入到页面输出的总时间;
2,在Jfinal的应用中,我们还会经常使用Directive自定义指令,还需要知道每个Directive输出耗时,便于知道耗时在哪
3,部分Render也会定义一些function,比如#define paginate,虽然一般耗时短,但也想明明白白知道耗时。
目前我的简单思路是:
1,写一个Handler,把优先级调到最高,这样所有的请求都包含在里面,
Stopwatch watch = Stopwatch.createStarted();
next.handle(target, request, response, isHandled);
long time = watch.elapsed(TimeUnit.MILLISECONDS);
logger.error("spendTime:{},{}", time, target);
2,在JbootDirectiveBase中
@OverRide
public void exec(Env env, Scope scope, Writer writer) {
Stopwatch watch = Stopwatch.createStarted();
scope = new Scope(scope);
scope.getCtrl().setLocalAssignment();
exprList.eval(scope);
onRender(env, scope, writer);
long time = watch.elapsed(TimeUnit.MILLISECONDS);
//需要反射获取子类的@JFinalDirective名称和类名
//logger.error("spendTime:{},{}", time, target);
}
3,写一个public class TimeRender extends TemplateRender
@OverRide
public void render() {
Stopwatch watch = Stopwatch.createStarted();
super.render();
long time = watch.elapsed(TimeUnit.MILLISECONDS);
logger.error("spendTime:{},{}", time, this.getView());
}
海哥看看能否增加.
The text was updated successfully, but these errors were encountered: