Created
April 10, 2025 08:48
-
-
Save sr9yar/9af9fc08d959a5140bc3c3126ee43b78 to your computer and use it in GitHub Desktop.
Simple code execution measurement
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(); | |
// process.hrtime(); | |
// https://nodejs.org/api/process.html#processhrtimetime | |
// [seconds, nanoseconds] | |
setTimeout(() => { | |
const end = new Date() - start; | |
const hrEnd = process.hrtime(hrStart); | |
console.log(`Exec time: ${end}`); | |
console.log(`Exec time hr: ${hrEnd[0]} sec and ${hrEnd[1] / 1000000} ms`); | |
}, Math.ceil(Math.random() * 3000)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment