/*! grafana - v3.1.0 - 2016-07-18
 * Copyright (c) 2016 Torkel Ödegaard; Licensed Apache-2.0 */

System.register(["jquery","angular"],function(a){var b,c,d,e;return{setters:[function(a){b=a},function(a){c=a}],execute:function(){d=function(){function a(){}return a.prototype.init=function(a,b){var c=this;this.enabled="development"===a.buildInfo.env,this.timings={},this.timings.appStart={loadStart:(new Date).getTime()},this.$rootScope=b,this.enabled&&(b.$watch(function(){return c.digestCounter++,!1},function(){}),b.onAppEvent("refresh",this.refresh.bind(this),b),b.onAppEvent("dashboard-fetch-end",this.dashboardFetched.bind(this),b),b.onAppEvent("dashboard-initialized",this.dashboardInitialized.bind(this),b),b.onAppEvent("panel-initialized",this.panelInitialized.bind(this),b))},a.prototype.refresh=function(){var a=this;this.timings.query=0,this.timings.render=0,setTimeout(function(){console.log("panel count: "+a.panelsInitCount),console.log("total query: "+a.timings.query),console.log("total render: "+a.timings.render),console.log("avg render: "+a.timings.render/a.panelsInitCount)},5e3)},a.prototype.dashboardFetched=function(){this.timings.dashboardLoadStart=(new Date).getTime(),this.panelsInitCount=0,this.digestCounter=0,this.panelsInitCount=0,this.panelsRendered=0,this.timings.query=0,this.timings.render=0},a.prototype.dashboardInitialized=function(){var a=this;setTimeout(function(){console.log("Dashboard::Performance Total Digests: "+a.digestCounter),console.log("Dashboard::Performance Total Watchers: "+a.getTotalWatcherCount()),console.log("Dashboard::Performance Total ScopeCount: "+a.scopeCount);var b=a.timings.lastPanelInitializedAt-a.timings.dashboardLoadStart;console.log("Dashboard::Performance All panels initialized in "+b+" ms");for(var c=window.performance.now(),d=0;d<30;d++)a.$rootScope.$apply();console.log("Dashboard::Performance Root Digest "+(window.performance.now()-c)/30)},3e3)},a.prototype.getTotalWatcherCount=function(){var a=0,d=0,e=b["default"](document.getElementsByTagName("body")),f=function(e){e.data().hasOwnProperty("$scope")&&(d++,c["default"].forEach(e.data().$scope.$$watchers,function(){a++})),c["default"].forEach(e.children(),function(a){f(b["default"](a))})};return f(e),this.scopeCount=d,a},a.prototype.renderingCompleted=function(a,b){this.$rootScope.panelsRendered=this.panelsRendered++,this.enabled&&(b.renderEnd=(new Date).getTime(),this.timings.query+=b.queryEnd-b.queryStart,this.timings.render+=b.renderEnd-b.renderStart)},a.prototype.panelInitialized=function(){this.enabled&&(this.panelsInitCount++,this.timings.lastPanelInitializedAt=(new Date).getTime())},a}(),a("Profiler",d),e=new d,a("profiler",e)}}});