mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix profiling code
This commit is contained in:
parent
975b53b318
commit
83c76981b2
@ -60,6 +60,14 @@ function (angular, $, config, moment) {
|
|||||||
$scope.updateSubmenuVisibility();
|
$scope.updateSubmenuVisibility();
|
||||||
$scope.setWindowTitleAndTheme();
|
$scope.setWindowTitleAndTheme();
|
||||||
|
|
||||||
|
if ($scope.profilingEnabled) {
|
||||||
|
$scope.performance.panels = [];
|
||||||
|
$scope.performance.panelCount = 0;
|
||||||
|
$scope.dashboard.rows.forEach(function(row) {
|
||||||
|
$scope.performance.panelCount += row.panels.length;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$scope.appEvent("dashboard-loaded", $scope.dashboard);
|
$scope.appEvent("dashboard-loaded", $scope.dashboard);
|
||||||
}).catch(function(err) {
|
}).catch(function(err) {
|
||||||
if (err.data && err.data.message) { err.message = err.data.message; }
|
if (err.data && err.data.message) { err.message = err.data.message; }
|
||||||
|
@ -51,6 +51,13 @@ function (angular, _, $) {
|
|||||||
|
|
||||||
$scope.onAppEvent('panel-initialized', function(evt, payload) {
|
$scope.onAppEvent('panel-initialized', function(evt, payload) {
|
||||||
self.registerPanel(payload.scope);
|
self.registerPanel(payload.scope);
|
||||||
|
|
||||||
|
if ($scope.profilingEnabled) {
|
||||||
|
$scope.performance.panelsInitialized++;
|
||||||
|
if ($scope.performance.panelsInitialized === $scope.performance.panelCount) {
|
||||||
|
$scope.performance.allPanelsInitialized = new Date().getTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.update(this.getQueryStringState());
|
this.update(this.getQueryStringState());
|
||||||
|
@ -95,7 +95,6 @@ class MetricsPanelCtrl extends PanelCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setTimeQueryStart() {
|
setTimeQueryStart() {
|
||||||
this.timing = {};
|
|
||||||
this.timing.queryStart = new Date().getTime();
|
this.timing.queryStart = new Date().getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ export class PanelCtrl {
|
|||||||
height: any;
|
height: any;
|
||||||
containerHeight: any;
|
containerHeight: any;
|
||||||
events: Emitter;
|
events: Emitter;
|
||||||
|
timing: any;
|
||||||
|
|
||||||
constructor($scope, $injector) {
|
constructor($scope, $injector) {
|
||||||
this.$injector = $injector;
|
this.$injector = $injector;
|
||||||
@ -38,6 +39,7 @@ export class PanelCtrl {
|
|||||||
this.$timeout = $injector.get('$timeout');
|
this.$timeout = $injector.get('$timeout');
|
||||||
this.editorTabIndex = 0;
|
this.editorTabIndex = 0;
|
||||||
this.events = new Emitter();
|
this.events = new Emitter();
|
||||||
|
this.timing = {};
|
||||||
|
|
||||||
var plugin = config.panels[this.panel.type];
|
var plugin = config.panels[this.panel.type];
|
||||||
if (plugin) {
|
if (plugin) {
|
||||||
@ -58,6 +60,20 @@ export class PanelCtrl {
|
|||||||
|
|
||||||
renderingCompleted() {
|
renderingCompleted() {
|
||||||
this.$scope.$root.performance.panelsRendered++;
|
this.$scope.$root.performance.panelsRendered++;
|
||||||
|
this.timing.renderEnd = new Date().getTime();
|
||||||
|
if (this.$scope.$root.profilingEnabled) {
|
||||||
|
this.$scope.$root.performance.panels.push({
|
||||||
|
panelId: this.panel.id,
|
||||||
|
query: this.timing.queryEnd - this.timing.queryStart,
|
||||||
|
render: this.timing.renderEnd - this.timing.renderStart,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this.$scope.$root.performance.panelsRendered === this.$scope.$root.performance.panelCount) {
|
||||||
|
this.$scope.$root.performance.allPanelsRendered = new Date().getTime();
|
||||||
|
var timeTaken = this.$scope.$root.performance.allPanelsRendered - this.$scope.$root.performance.dashboardLoadStart;
|
||||||
|
console.log("Dashboard::Performance - All panels rendered in " + timeTaken + " ms");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
@ -169,6 +185,7 @@ export class PanelCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.calculatePanelHeight();
|
this.calculatePanelHeight();
|
||||||
|
this.timing.renderStart = new Date().getTime();
|
||||||
this.events.emit('render', payload);
|
this.events.emit('render', payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user