cacert-testmgr/external/ZendFramework-1.9.5/externals/dojo/dojox/lang/aspect/timer.js
Markus Warg 8398c9048d initially import ZendFramework-1.9.5 into repository
code was modified slightly, so the code differs from the original downloadable 1.9.5 version
2010-03-31 10:12:32 +02:00

33 lines
No EOL
670 B
JavaScript

dojo.provide("dojox.lang.aspect.timer");
(function(){
var aop = dojox.lang.aspect,
uniqueNumber = 0;
var Timer = function(name){
this.name = name || ("DojoAopTimer #" + ++uniqueNumber);
this.inCall = 0;
};
dojo.extend(Timer, {
before: function(/*arguments*/){
if(!(this.inCall++)){
console.time(this.name);
}
},
after: function(/*excp*/){
if(!--this.inCall){
console.timeEnd(this.name);
}
}
});
aop.timer = function(/*String?*/ name){
// summary:
// Returns an object, which can be used to time calls to methods.
//
// name:
// The optional unique name of the timer.
return new Timer(name); // Object
};
})();