author | Giulio 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) |
commit | ef68436ac04da078ffdcacd7e1f785473a303d45 (patch) (unidiff) | |
tree | c403752d66a2c4775f00affd4fa8431b29c5b68c /frontend/beta/js/YUI-extensions/Bench.js | |
parent | 597ecfbc0249d83e1b856cbd558340c01237a360 (diff) | |
download | clipperz-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) (show whitespace changes)
-rw-r--r-- | frontend/beta/js/YUI-extensions/Bench.js | 40 |
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 | ||
3 | YAHOO.ext.util.Bench = function(){ | ||
4 | this.timers = {}; | ||
5 | this.lastKey = null; | ||
6 | }; | ||
7 | YAHOO.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 | }; | ||