From 541bb378ddece2eab135a8066a16994e94436dea Mon Sep 17 00:00:00 2001 From: Giulio Cesare Solaroli Date: Mon, 03 Oct 2011 16:04:12 +0000 Subject: Merge pull request #1 from gcsolaroli/master First version of the restructured repository --- (limited to 'frontend/beta/js/YUI-extensions/Bench.js') diff --git a/frontend/beta/js/YUI-extensions/Bench.js b/frontend/beta/js/YUI-extensions/Bench.js new file mode 100644 index 0000000..6921131 --- a/dev/null +++ b/frontend/beta/js/YUI-extensions/Bench.js @@ -0,0 +1,40 @@ +// @deprecated +// Use YAHOO.timer() instead +YAHOO.ext.util.Bench = function(){ + this.timers = {}; + this.lastKey = null; +}; +YAHOO.ext.util.Bench.prototype = { + start : function(key){ + this.lastKey = key; + this.timers[key] = {}; + this.timers[key].startTime = new Date().getTime(); + }, + + stop : function(key){ + key = key || this.lastKey; + this.timers[key].endTime = new Date().getTime(); + }, + + getElapsed : function(key){ + key = key || this.lastKey; + return this.timers[key].endTime - this.timers[key].startTime; + }, + + toString : function(html){ + var results = ""; + for(var key in this.timers){ + if(typeof this.timers[key] != 'function'){ + results += key + ":\t" + (this.getElapsed(key) / 1000) + " seconds\n"; + } + } + if(html){ + results = results.replace("\n", '
'); + } + return results; + }, + + show : function(){ + alert(this.toString()); + } +}; -- cgit v0.9.0.2