Skip to content

Instantly share code, notes, and snippets.

@othiym23
Created August 25, 2012 22:22
Show Gist options
  • Save othiym23/3471556 to your computer and use it in GitHub Desktop.
Save othiym23/3471556 to your computer and use it in GitHub Desktop.
function Timer () {
this.hrStart = process.hrTime();
}
Timer.prototype.end = function () {
this.duration = process.hrTime(this.hrStart);
};
Timer.prototype.durationInMillis = function () {
return this.duration[0] * 1000 + this.duration[1] / 1000 / 1000;
}
var timer = new Timer();
setTimeout(function () { timer.end(); assert.ok(timer.durationInMillis() >= 5); }, 5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment