summaryrefslogtreecommitdiff
path: root/frontend/beta/js/YUI-extensions/Bench.js
Unidiff
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 @@
1// @deprecated
2// Use YAHOO.timer() instead
3YAHOO.ext.util.Bench = function(){
4 this.timers = {};
5 this.lastKey = null;
6};
7YAHOO.ext.util.Bench.prototype = {
8 start : function(key){
9 this.lastKey = key;
10 this.timers[key] = {};
11 this.timers[key].startTime = new Date().getTime();
12 },
13
14 stop : function(key){
15 key = key || this.lastKey;
16 this.timers[key].endTime = new Date().getTime();
17 },
18
19 getElapsed : function(key){
20 key = key || this.lastKey;
21 return this.timers[key].endTime - this.timers[key].startTime;
22 },
23
24 toString : function(html){
25 var results = "";
26 for(var key in this.timers){
27 if(typeof this.timers[key] != 'function'){
28 results += key + ":\t" + (this.getElapsed(key) / 1000) + " seconds\n";
29 }
30 }
31 if(html){
32 results = results.replace("\n", '<br>');
33 }
34 return results;
35 },
36
37 show : function(){
38 alert(this.toString());
39 }
40};