Created
January 22, 2013 16:32
-
-
Save dbrockman/4596073 to your computer and use it in GitHub Desktop.
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
// 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