Skip to content

Instantly share code, notes, and snippets.

@alexrqs
Last active July 16, 2023 17:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexrqs/872b35011145f9e97638cf195a3b59c8 to your computer and use it in GitHub Desktop.
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
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