2016-07-21 6 views
0

AngualrJS + spring-boot appで作業していました。すべてのデータを読み込むにはどれくらいの時間がかかるのかなど、ユーザーにページごとのパフォーマンスを示す必要があります。AngualrJS + spring-boot appのパフォーマンスを監視する方法

  1. このプラグインは何ですか?まだ見つかりません

  2. 複数のアヤックスコールと1つのリクエストが組み合わされています。これらのコールをすべて計算して返信する方法は、クロムのネットワークモニタのようです。 。

答えて

0

注:どのような要求でも、モニターを停止するタイミングを知ることができないため、ロード時間が長くなります。

私はいくつかの研究を行なったし、このhttp://www.bennadel.com/blog/2777-monitoring-http-activity-with-http-interceptors-in-angularjs.htm

を発見し、私は自分のプロファイラを作成するためにインターセプタを使用します。

<!--some html-->
<div>{{profiler.time}}</div>

angular.module('app') 
    .run(function ($rootScope){ 
     $rootScope.$on('$stateChangeStart', function (event) { 
      Profiler.reset(); 
      $rootScope.profiler = Profiler; 
     }); 
    }) 
    .config(function ($httpProvider){ 
     $httpProvider.interceptors.push('profilerInterceptor'); 
    }) 
    .factory('profilerInterceptor', function ($q, Profiler) { 
     return { 
      request: function (request) { 
       if (Profiler.startTime == null) { 
        Profiler.startTime = new Date(); 
       } 
       return request; 
      }, 
      response: function (response) { 
       Profiler.refresh(); 
       return response; 
      } 
     }; 
    }) 
    .service('Profiler', function() { 
     return { 
      startTime: null, 
      endTime: null, 
      time: 0, 
      reset: function() { 
       this.startTime = null; 
      }, 
      refresh: function() { 
       this.endTime = new Date(); 
       this.time = (this.endTime - this.startTime)/1000; 
      } 
     }; 
    }); 
関連する問題