Skip to content

Instantly share code, notes, and snippets.

@linuxsable
Created November 8, 2011 18:57
Show Gist options
  • Select an option

  • Save linuxsable/1348733 to your computer and use it in GitHub Desktop.

Select an option

Save linuxsable/1348733 to your computer and use it in GitHub Desktop.
// Use for timing tests
function Timer() {
this.startTime = 0;
this.endTime = 0;
this.elapsed = 0;
this.start = function() {
this.startTime = Date.now();
return this;
};
this.s = function() {
return this.start();
};
this.end = function() {
this.endTime = Date.now();
return this;
};
this.e = function() {
return this.end();
};
this.elapsed = function() {
this.elapsed = ( (this.endTime - this.startTime) / 1000 );
console.log(this.elapsed);
return this.elapsed;
};
this.el = function() {
return this.elapsed();
}
this.clear = function() {
this.startTime = 0;
this.endTime = 0;
this.elapsed = 0;
return this;
};
this.reset = function() {
this.clear();
return this;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment