process.hrtime.bigint()
- 返回: <bigint>
process.hrtime()
方法的 bigint
版本以纳秒为单位返回当前高解析度实时作为 bigint
。
与 process.hrtime()
不同,它不支持额外的 time
参数,因为可以直接通过减去两个 bigint
来计算差异。
import { hrtime } from 'node:process';
const start = hrtime.bigint();
// 191051479007711n
setTimeout(() => {
const end = hrtime.bigint();
// 191052633396993n
console.log(`Benchmark took ${end - start} nanoseconds`);
// 基准测试耗时 1154389282 纳秒
}, 1000);
const { hrtime } = require('node:process');
const start = hrtime.bigint();
// 191051479007711n
setTimeout(() => {
const end = hrtime.bigint();
// 191052633396993n
console.log(`Benchmark took ${end - start} nanoseconds`);
// 基准测试耗时 1154389282 纳秒
}, 1000);
- Returns: <bigint>
The bigint
version of the process.hrtime()
method returning the
current high-resolution real time in nanoseconds as a bigint
.
Unlike process.hrtime()
, it does not support an additional time
argument since the difference can just be computed directly
by subtraction of the two bigint
s.
import { hrtime } from 'node:process';
const start = hrtime.bigint();
// 191051479007711n
setTimeout(() => {
const end = hrtime.bigint();
// 191052633396993n
console.log(`Benchmark took ${end - start} nanoseconds`);
// Benchmark took 1154389282 nanoseconds
}, 1000);
const { hrtime } = require('node:process');
const start = hrtime.bigint();
// 191051479007711n
setTimeout(() => {
const end = hrtime.bigint();
// 191052633396993n
console.log(`Benchmark took ${end - start} nanoseconds`);
// Benchmark took 1154389282 nanoseconds
}, 1000);