High precision time
const work = () => { | |
for (let i = 0; i < 1000000; i++) {} | |
}; | |
const start = process.hrtime.bigint(); | |
work(); | |
const end = process.hrtime.bigint(); | |
console.log( | |
`Benchmark took ${Number(end - start) / 1000 / 1000 / 1000} seconds` | |
); | |
console.log(`Benchmark took ${Number(end - start) / 1000 / 1000} milliseconds`); | |
console.log(`Benchmark took ${Number(end - start) / 1000} microseconds`); | |
console.log(`Benchmark took ${Number(end - start)} nanoseconds`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment