0
点赞
收藏
分享

微信扫一扫

javascript 获取毫秒、纳秒时间戳

鲤鱼打个滚 2022-05-05 阅读 182
var date = Date.now()
console.log(date)//毫秒时间戳
console.log(date)
console.log(date)

const start = process.hrtime.bigint(); //纳秒时间戳
// 191051479007711n

setTimeout(() => {
  const end = process.hrtime.bigint();
  // 191052633396993n

  console.log(`Benchmark took ${end - start} nanoseconds`);
  // Benchmark took 1154389282 nanoseconds
}, 1000);
举报

相关推荐

0 条评论