blob: 69211319c0710a392f452b11205b32a0b04f79d0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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());
}
};
|