Skip to content

Instantly share code, notes, and snippets.

@DimitarChristoff
Created March 16, 2011 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DimitarChristoff/872473 to your computer and use it in GitHub Desktop.
Save DimitarChristoff/872473 to your computer and use it in GitHub Desktop.
mootools timer class
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