Skip to content

Instantly share code, notes, and snippets.

@dbrockman
Created January 22, 2013 16:32
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 dbrockman/4596073 to your computer and use it in GitHub Desktop.
Save dbrockman/4596073 to your computer and use it in GitHub Desktop.
// high-resolution time diff in milliseconds
function hrmstime(t) {
if (t) {
t = process.hrtime(t);
return (t[0] * 1e9 + t[1]) / 1e6;
}
return process.hrtime();
}
// Start time
var time = hrmstime();
// Run the code
slowFn();
// Time diff
time = hrmstime(time);
console.log('Done in %d ms', hrmstime(time));
// -> Done in 22.555161 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment