var perf=angular.module("performance",[]);perf.directive("performance",[function(){return{restrict:"A",link:function(e,n,r){var i=(new Date).getTime();var t=[];e.$on("PERF_DONE",function(e,n){var o=t.indexOf(n);if(o>=0)t.splice(o,1);if(o>=0&&t.length==0){var a=(new Date).getTime()-i;var c=0;if(window.performance){c=window.performance.timing.domComplete-window.performance.timing.fetchStart}c=!c||c<0?0:c;a=!a||a<0?0:a;var f=new Image;f.src=r.performanceBeacon+"?content="+a+"&initial="+c+"&name="+r.performance}});e.$on("PERF_REGISTER",function(e,n){t.push(n)})}}}]);perf.directive("performanceLoaded",["$timeout",function(e){return{restrict:"A",link:function(n,r,i){e(function(){n.$emit("PERF_REGISTER",n.$id)},0);var t=n.$watch(i.performanceLoaded,function(e,r){if(e){n.$emit("PERF_DONE",n.$id);t()}})}}}]);