gpt4 book ai didi

javascript - setTimeOut 产生 233 fps 而 requestAnimationFrame 产生 61

转载 作者:数据小太阳 更新时间:2023-10-29 05:04:40 29 4
gpt4 key购买 nike

我在 Chrome 上做了一些测试,requestAnimationFrame 产生了 61 fps 而 setTimeOut( callback, 0 ) 产生了 233 fps。
如果一个人想要超过 61 fps(我不确定这是为了什么)但是使用 setTimeOut 渲染并只使用 requestAnimationFrame 来检测窗口何时失去焦点然后停止超时直到焦点不是更好吗返回?

还有一个附带问题:除了不调用回调的 requestAnimationFrame 之外,还有其他方法可以检测窗口何时失去焦点吗?

最佳答案

请求动画帧与您的显示器刷新率同步(动画帧数多于您在屏幕上实际显示的帧数是没有用的)

这是来自 mozilla 文档的引用:https://developer.mozilla.org/en/DOM/Animations_using_MozBeforePaint

Frame rate control

MozBeforePaint won't fire more than a fixed number of times per second, e.g. 50 or 60. This is intentional, because modern operating systems and hardware won't let the browser display more frames than that anyway. Limiting the frame rate avoids wasting work, thereby saving CPU usage and power and improving overall system performance.

关于javascript - setTimeOut 产生 233 fps 而 requestAnimationFrame 产生 61,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8591795/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com