|
|
@@ -2,8 +2,9 @@ define([
|
|
|
'angular',
|
|
|
'config',
|
|
|
'lodash',
|
|
|
+ 'jquery',
|
|
|
],
|
|
|
-function (angular, config, _) {
|
|
|
+function (angular, config, _, $) {
|
|
|
"use strict";
|
|
|
|
|
|
var module = angular.module('grafana.controllers');
|
|
|
@@ -11,6 +12,20 @@ function (angular, config, _) {
|
|
|
module.controller('GrafanaCtrl', function($scope, alertSrv, grafanaVersion, $rootScope) {
|
|
|
|
|
|
$scope.grafanaVersion = grafanaVersion[0] === '@' ? 'master' : grafanaVersion;
|
|
|
+ $scope.performance = { loadStart: new Date().getTime() };
|
|
|
+
|
|
|
+ var count = 0;
|
|
|
+ $scope.$watch(function() {
|
|
|
+ console.log(1);
|
|
|
+ count++;
|
|
|
+ }, function() {
|
|
|
+ });
|
|
|
+
|
|
|
+ setTimeout(function() {
|
|
|
+ console.log("Dashboard::Performance Total Digests: " + count);
|
|
|
+ console.log("Dashboard::Performance Total Watchers: " + $scope.getTotalWatcherCount());
|
|
|
+ console.log("Dashboard::Performance Total ScopeCount: " + $scope.performance.scopeCount);
|
|
|
+ }, 3000);
|
|
|
|
|
|
$scope.init = function() {
|
|
|
$scope._ = _;
|
|
|
@@ -46,6 +61,29 @@ function (angular, config, _) {
|
|
|
"#E0F9D7","#FCEACA","#CFFAFF","#F9E2D2","#FCE2DE","#BADFF4","#F9D9F9","#DEDAF7" //7
|
|
|
];
|
|
|
|
|
|
+ $scope.getTotalWatcherCount = function() {
|
|
|
+ var count = 0;
|
|
|
+ var scopes = 0;
|
|
|
+ var root = $(document.getElementsByTagName('body'));
|
|
|
+
|
|
|
+ var f = function (element) {
|
|
|
+ if (element.data().hasOwnProperty('$scope')) {
|
|
|
+ scopes++;
|
|
|
+ angular.forEach(element.data().$scope.$$watchers, function () {
|
|
|
+ count++;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ angular.forEach(element.children(), function (childElement) {
|
|
|
+ f($(childElement));
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ f(root);
|
|
|
+ $scope.performance.scopeCount = scopes;
|
|
|
+ return count;
|
|
|
+ };
|
|
|
+
|
|
|
$scope.init();
|
|
|
|
|
|
});
|