监控GWT JavaScript/客户端代码

监控GWT JavaScript/客户端代码,javascript,performance,gwt,analysis,monitor,Javascript,Performance,Gwt,Analysis,Monitor,我想用GWT监视每个被调用的客户端函数。 我尝试了几个GWTAOP框架。但是,我没有找到任何与GWT2.7兼容的 是否有人能够监视每个被调用的客户端函数?我希望它能够自动监视客户端代码的性能。手动添加事件/调用在1k methods项目中非常繁琐…您可以通过GWT SuperDevMode查看/调试客户端JS代码。您可以使用window.performance API: var t0 = performance.now(); doSomething(); var t1 = performance

我想用GWT监视每个被调用的客户端函数。 我尝试了几个GWTAOP框架。但是,我没有找到任何与GWT2.7兼容的


是否有人能够监视每个被调用的客户端函数?我希望它能够自动监视客户端代码的性能。手动添加事件/调用在1k methods项目中非常繁琐…

您可以通过GWT SuperDevMode查看/调试客户端JS代码。

您可以使用window.performance API:

var t0 = performance.now();
doSomething();
var t1 = performance.now();
console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.")
使用它很容易

创建一个本机JSNI方法,以便您可以将其作为本地GWT模块函数进行访问…:

public static native void weave() /*-{
    $wnd.jQuery.aop.around({
        target : this,
        method : 'viewScene.*'
    }, function(invocation) {
        var t0 = $wnd.performance.now();
        var result = invocation.proceed();
        var t1 = $wnd.performance.now();
        console.log("Call to " + invocation.method + " took " + (t1 - t0)
                + " milliseconds.")
        return result;
    });
}-*/;

现在唯一的挑战是如何将函数viewsecene_0_g$与原始代码关联。但是,使用sourcemaps应该可以做到这一点。

那么我如何通过编程获得调用时间戳/持续时间和被调用的方法名称呢?自从您引导我使用JavaScript AOP以来,我将您的提示标记为答案。谢谢:我们已经设置了一个小示例,说明如何监视GWT 2.7 JS代码: