高精度时间戳
毫秒级时间戳
获取毫秒级时间戳
Date.now
微秒级时间戳
获取微秒级时间戳
performance.timing.navigationStart + performance.now()
与 Date.now
不同,window.performance.now()
返回的时间戳没有被限制在一毫秒的精确度内,而是使用了一个浮点数来达到微秒级别的精确度。
另外,window.performance.now()
是以一个恒定的速率慢慢增加的,它不会受到系统时间的影响(系统可能被其他软件调整)。
另外,performance.timing.navigationStart + performance.now()
约等于 Date.now()
详见:https://developer.mozilla.org/zh-CN/docs/Web/API/Performance/now