process.hrtime.bigint()
Returns a high-resolution real-time timestamp in nanoseconds.
Syntax
process.hrtime.bigint() Returns
bigint — Nanoseconds from an arbitrary monotonic origin.
Examples
const start = process.hrtime.bigint();
for (let i = 0; i < 1e6; i++);
const ns = process.hrtime.bigint() - start;
console.log(Number(ns) / 1e6, 'ms');
Output
2.41 ms
const t0 = process.hrtime.bigint();
await fetch('https://example.com');
console.log(`${(process.hrtime.bigint() - t0) / 1000000n}ms`);
Output
143ms
Notes
Monotonic and unaffected by wall-clock changes, so it is correct for
measuring durations (unlike `Date.now()`). The legacy
`process.hrtime()` returns a `[seconds, nanoseconds]` tuple; the
bigint form is simpler. `performance.now()` is a portable alternative.