diff --git a/src/app/controllers/console-ctrl.js b/src/app/controllers/console-ctrl.js index e2194b8eca9..5b2d277f9d1 100644 --- a/src/app/controllers/console-ctrl.js +++ b/src/app/controllers/console-ctrl.js @@ -15,20 +15,6 @@ function (angular, _, moment) { var events = []; - var oldLog = console.log; - console.log = function (message) { - try { - if (_.isObject(message)) { - message = angular.toJson(message); - if (message.length > 50) { - message = message.substring(0, 50); - } - } - events.push(new ConsoleEvent('log', message, {})); - oldLog.apply(console, arguments); - } catch (e) { } - }; - function ConsoleEvent(type, title, data) { this.type = type; this.title = title; @@ -112,6 +98,7 @@ function (angular, _, moment) { $httpProvider.interceptors.push('mupp'); }); + module.controller('ConsoleCtrl', function($scope) { $scope.events = events; diff --git a/src/app/controllers/dash.js b/src/app/controllers/dash.js index 3706a0a4109..177b5b4fec7 100644 --- a/src/app/controllers/dash.js +++ b/src/app/controllers/dash.js @@ -26,6 +26,10 @@ function (angular, $, config, _) { $scope.setupDashboard = function(event, dashboardData) { timer.cancel_all(); + $scope.performance.dashboardLoadStart = new Date().getTime(); + $scope.performance.panelsInitialized = 0; + $scope.performance.panelsRendered= 0; + $scope.dashboard = dashboardSrv.create(dashboardData); $scope.dashboardViewState = dashboardViewStateSrv.create($scope); diff --git a/src/app/controllers/grafanaCtrl.js b/src/app/controllers/grafanaCtrl.js index eaf3dfd0422..3c8630d71f0 100644 --- a/src/app/controllers/grafanaCtrl.js +++ b/src/app/controllers/grafanaCtrl.js @@ -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(); }); diff --git a/src/app/partials/dashboard.html b/src/app/partials/dashboard.html index b6a7287f536..7a4d9fb92ca 100644 --- a/src/app/partials/dashboard.html +++ b/src/app/partials/dashboard.html @@ -98,7 +98,7 @@ -