• 返回: {bigint}

    [process.hrtime()] 方法的 bigint 版本,返回当前的高精度实际时间(以纳秒为单位的 bigint 型)。

    与 [process.hrtime()] 不同,它不支持额外的 time 参数,因为可以直接通过两个 bigint 相减来计算差异。

    1. const start = process.hrtime.bigint();
    2. // 191051479007711n
    3. setTimeout(() => {
    4. const end = process.hrtime.bigint();
    5. // 191052633396993n
    6. console.log(`基准测试耗时 ${end - start} 纳秒`);
    7. // 基准测试耗时 1154389282 纳秒
    8. }, 1000);