How to measure time taken by a function to execute ?
You can try this :
Output:
We can use console.time: (non-standard)
We could use the standard performance.now() API:
Use new Date().getTime()
.
The getTime() method returns the number of milliseconds.
To get precise values we should use Performance interface . It's supported in modern versions of Firefox, Chrome , Opera and IE.
Use add operator:
process.hrtime() is available within Node.js - It returns a value in nanoseconds.