Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to Measure Execution Time in Node.js
var start = new Date();
var hrstart = process.hrtime();
setTimeout(function (argument) {
// execution time simulated with setTimeout function
var end = new Date() - start,
hrend = process.hrtime(hrstart);"Execution time: %dms", end);"Execution time (hr): %ds %dms", hrend[0], hrend[1]/1000000);
}, 1);
// Execution time: 1ms
// Execution time (hr): 0s 1.025075ms
Copy link

Thank you, very useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment