Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我使用 setTimeout 如下
setTimeout(function (){ console.log("Delay"); }, 100);
但是我们怎么知道 100 毫秒对于所有条件下的所有计算机来说都是正确的时间量呢?
如果您想构建一个依赖时间的系统 - 在页面上应用“基准”并测量时间。例如,以毫秒为单位获取 time(),运行一个半重循环,然后获取另一个 time() 并计算两次之间的差异。然后,您可以使用一系列兼容的延迟时间来获得大量结果。