7
YUI.add("profiler",function(Y){var L=Y.Lang;Y.Profiler={_container:{},_report:{},_saveData:function(name,duration){var functionData=this._report[name];functionData.calls++;functionData.points.push(duration);if(functionData.calls>1){functionData.avg=((functionData.avg*(functionData.calls-1))+duration)/functionData.calls;functionData.min=Math.min(functionData.min,duration);functionData.max=Math.max(functionData.max,duration);}else{functionData.avg=duration;functionData.min=duration;functionData.max=duration;}},getAverage:function(name){return this._report[name].avg;},getCallCount:function(name){return this._report[name].calls;},getMax:function(name){return this._report[name].max;},getMin:function(name){return this._report[name].min;},getFunctionReport:function(name){return this._report[name];},getFullReport:function(filter){filter=filter||function(){return true;};if(typeof filter=="function"){var report={};for(var name in this._report){if(filter(this._report[name])){report[name]=this._report[name];}}return report;}},registerConstructor:function(name,owner){this.registerFunction(name,owner,true);},registerFunction:function(name,owner,registerPrototype){var funcName=(name.indexOf(".")>-1?name.substring(name.lastIndexOf(".")+1):name);if(!L.isObject(owner)){owner=eval(name.substring(0,name.lastIndexOf(".")));}var method=owner[funcName];var prototype=method.prototype;if(L.isFunction(method)&&!method.__yuiProfiled){this._container[name]=method;owner[funcName]=function(){var start=new Date();var retval=method.apply(this,arguments);var stop=new Date();Y.Profiler._saveData(name,stop-start);return retval;};Y.mix(owner[funcName],method);owner[funcName].__yuiProfiled=true;owner[funcName].prototype=prototype;this._container[name].__yuiOwner=owner;this._container[name].__yuiFuncName=funcName;if(registerPrototype){this.registerObject(name+".prototype",prototype);}this._report[name]={calls:0,max:0,min:0,avg:0,points:[]};}return method;},registerObject:function(name,object,recurse){object=(L.isObject(object)?object:eval(name));this._container[name]=object;for(var prop in object){if(typeof object[prop]=="function"){if(prop!="constructor"&&prop!="superclass"){this.registerFunction(name+"."+prop,object);}}else{if(typeof object[prop]=="object"&&recurse){this.registerObject(name+"."+prop,object[prop],recurse);}}}},unregisterConstructor:function(name){if(L.isFunction(this._container[name])){this.unregisterFunction(name,true);}},unregisterFunction:function(name,unregisterPrototype){if(L.isFunction(this._container[name])){if(unregisterPrototype){this.unregisterObject(name+".prototype",this._container[name].prototype);}var owner=this._container[name].__yuiOwner;var funcName=this._container[name].__yuiFuncName;delete this._container[name].__yuiOwner;delete this._container[name].__yuiFuncName;owner[funcName]=this._container[name];delete this._container[name];delete this._report[name];}},unregisterObject:function(name,recurse){if(L.isObject(this._container[name])){var object=this._container[name];for(var prop in object){if(typeof object[prop]=="function"){this.unregisterFunction(name+"."+prop);}else{if(typeof object[prop]=="object"&&recurse){this.unregisterObject(name+"."+prop,recurse);}}}delete this._container[name];}}};},"3.0.0pr2");