Last active
April 24, 2024 14:10
-
-
Save arnaudrenaud/fd560bec78a133d2c3b1bfffb76195a7 to your computer and use it in GitHub Desktop.
Measure execution time in Node.js
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 { performance } = require("perf_hooks"); | |
const start1 = performance.now(); | |
JSON.stringify({ emailAddress: "[email protected]" }); | |
const end1 = performance.now(); | |
console.log( | |
`Time taken to execute JSON.stringify function is ${end1 - start1}ms.` | |
); | |
const start2 = performance.now(); | |
JSON.parse('{"emailAddress": "[email protected]"}'); | |
const end2 = performance.now(); | |
console.log( | |
`Time taken to execute JSON.parse function is ${end2 - start2}ms.` | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment