Last active
July 16, 2023 17:48
-
-
Save alexrqs/872b35011145f9e97638cf195a3b59c8 to your computer and use it in GitHub Desktop.
Log nodejs hrtime to measure time of a process or function for nodejs
This file contains hidden or 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
const start = new Date() | |
const hrstart = process.hrtime() | |
const simulateTime = 500 | |
setTimeout(function(argument) { | |
// execution time simulated with setTimeout function | |
const end = new Date() - start | |
const hrend = process.hrtime(hrstart) | |
console.info('Execution time: %dms', end) | |
console.info('Execution time (hr): %ds %dms', hrend[0], hrend[1] / 1000000) | |
}, simulateTime) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment