diff --git a/src/app/controllers/console-ctrl.js b/src/app/controllers/console-ctrl.js index 5b2d277f9d1..f5ce873bbfd 100644 --- a/src/app/controllers/console-ctrl.js +++ b/src/app/controllers/console-ctrl.js @@ -98,7 +98,6 @@ 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 177b5b4fec7..90546486b2e 100644 --- a/src/app/controllers/dash.js +++ b/src/app/controllers/dash.js @@ -26,9 +26,9 @@ 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; + $rootScope.performance.dashboardLoadStart = new Date().getTime(); + $rootScope.performance.panelsInitialized = 0; + $rootScope.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 3c8630d71f0..c25742c7992 100644 --- a/src/app/controllers/grafanaCtrl.js +++ b/src/app/controllers/grafanaCtrl.js @@ -12,29 +12,21 @@ function (angular, config, _, $) { module.controller('GrafanaCtrl', function($scope, alertSrv, grafanaVersion, $rootScope) { $scope.grafanaVersion = grafanaVersion[0] === '@' ? 'master' : grafanaVersion; - $scope.performance = { loadStart: new Date().getTime() }; + $scope.consoleEnabled = (window.localStorage && window.localStorage.grafanaConsole === 'true'); - 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); + $rootScope.profilingEnabled = (window.localStorage && window.localStorage.profilingEnabled === 'true'); + $rootScope.performance = { loadStart: new Date().getTime() }; $scope.init = function() { $scope._ = _; + if ($rootScope.profilingEnabled) { + $scope.initProfiling(); + } + $scope.dashAlerts = alertSrv; $scope.grafana = { style: 'dark' }; - - $scope.consoleEnabled = (window.localStorage && window.localStorage.grafanaConsole === 'true'); }; $scope.toggleConsole = function() { @@ -80,10 +72,26 @@ function (angular, config, _, $) { }; f(root); - $scope.performance.scopeCount = scopes; + $rootScope.performance.scopeCount = scopes; return count; }; + $scope.initProfiling = function() { + 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(); }); diff --git a/src/app/services/panelSrv.js b/src/app/services/panelSrv.js index 04948132bea..78eab13798d 100644 --- a/src/app/services/panelSrv.js +++ b/src/app/services/panelSrv.js @@ -130,10 +130,12 @@ function (angular, _) { } } - $scope.performance.panelsInitialized++; - if ($scope.performance.panelsInitialized === $scope.dashboard.rows.length) { - var timeTaken = new Date().getTime() - $scope.performance.dashboardLoadStart; - console.log("Dashboard::Performance - All panels initialized in " + timeTaken + " ms"); + if ($rootScope.profilingEnabled) { + $rootScope.performance.panelsInitialized++; + if ($rootScope.performance.panelsInitialized === $scope.dashboard.rows.length) { + var timeTaken = new Date().getTime() - $scope.performance.dashboardLoadStart; + console.log("Dashboard::Performance - All panels initialized in " + timeTaken + " ms"); + } } }; });