2019-10-14 03:27:47 -05:00
|
|
|
import { GrafanaRootScope } from 'app/routes/GrafanaCtrl';
|
|
|
|
|
2016-06-07 23:51:01 -05:00
|
|
|
export class Profiler {
|
|
|
|
panelsRendered: number;
|
|
|
|
enabled: boolean;
|
2019-10-14 03:27:47 -05:00
|
|
|
$rootScope: GrafanaRootScope;
|
2018-05-24 08:26:27 -05:00
|
|
|
window: any;
|
2016-06-07 23:51:01 -05:00
|
|
|
|
2019-10-14 03:27:47 -05:00
|
|
|
init(config: any, $rootScope: GrafanaRootScope) {
|
2016-06-07 23:51:01 -05:00
|
|
|
this.$rootScope = $rootScope;
|
2018-05-24 08:26:27 -05:00
|
|
|
this.window = window;
|
2016-06-07 23:51:01 -05:00
|
|
|
|
|
|
|
if (!this.enabled) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-13 02:38:19 -05:00
|
|
|
renderingCompleted() {
|
2016-06-17 01:49:11 -05:00
|
|
|
// add render counter to root scope
|
|
|
|
// used by phantomjs render.js to know when panel has rendered
|
2016-07-29 08:04:51 -05:00
|
|
|
this.panelsRendered = (this.panelsRendered || 0) + 1;
|
2018-05-24 08:26:27 -05:00
|
|
|
|
|
|
|
// this window variable is used by backend rendering tools to know
|
|
|
|
// all panels have completed rendering
|
|
|
|
this.window.panelsRendered = this.panelsRendered;
|
2016-06-07 23:51:01 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-29 07:26:50 -05:00
|
|
|
const profiler = new Profiler();
|
2017-12-19 09:06:54 -06:00
|
|
|
export { profiler };
|