Created
March 16, 2011 13:17
-
-
Save DimitarChristoff/872473 to your computer and use it in GitHub Desktop.
mootools timer class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var timer = new Class({ | |
options: { | |
pause: 0 | |
}, | |
Implements: [Options,Events], | |
initialize: function(options) { | |
this.setOptions(options); | |
this.counter = 0; | |
}, | |
startTest: function(fn, runs, label) { | |
this.start = new Date(); | |
var runs = runs || 1; | |
while(runs--) { | |
fn.apply(this); | |
} | |
this.end = new Date(); | |
this.timeElapsed = this.end.getTime() - this.start.getTime(); | |
this.counter++; | |
this.label = label || "n/a"; | |
this.fireEvent("complete", this); | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment