summaryrefslogtreecommitdiff
path: root/frontend/beta/js/YUI-extensions/Bench.js
authorGiulio Cesare Solaroli <giulio.cesare@clipperz.com>2011-10-02 23:56:18 (UTC)
committer Giulio Cesare Solaroli <giulio.cesare@clipperz.com>2011-10-02 23:56:18 (UTC)
commitef68436ac04da078ffdcacd7e1f785473a303d45 (patch) (side-by-side diff)
treec403752d66a2c4775f00affd4fa8431b29c5b68c /frontend/beta/js/YUI-extensions/Bench.js
parent597ecfbc0249d83e1b856cbd558340c01237a360 (diff)
downloadclipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.zip
clipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.tar.gz
clipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.tar.bz2
First version of the newly restructured repository
Diffstat (limited to 'frontend/beta/js/YUI-extensions/Bench.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/YUI-extensions/Bench.js40
1 files changed, 40 insertions, 0 deletions
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", '<br>');
+ }
+ return results;
+ },
+
+ show : function(){
+ alert(this.toString());
+ }
+};