如何准确测量HTML5浏览器帧率(FPS)?
在现代 HTML5 浏览器中测量帧速率(即 FPS)最准确的方法是什么?我对 Canvas 动画的 FPS 特别感兴趣。
http://weblogs.mozillazine.org/roc/archives/2010/11 /measuring_fps.html 会告诉您尝试通过计算 setTimeout 运行的频率来测量帧速率是不准确的。浏览器可以在屏幕绘制之间多次运行超时回调。
原来 Mozilla 有一个 window.mozPaintCount https://developer.mozilla.org/en/DOM /window.mozPaintCount 可用,它应该提供准确的 FPS。然而,这只适用于 Mozilla。
Chrome 存在一个类似的未决问题:http://code.google .com/p/chromium/issues/detail?id=65348
在 Chrome 中检查硬件加速 FPS 的手动方法是获取 Chrome Beta 频道(截至发布日期)并转到 about:flags 并打开在FPS 计数器。但是,在 Mac 上,仅在使用 WebGL 时才会启用加速。因此,无法在 Mac 版 Chrome 上检查 Canvas 的 FPS。
准确测量 HTML5 FPS 的其他策略有哪些?
谢谢!
What is the most accurate way to measure framerates, i.e. FPS, in modern HTML5 browsers? I'm specifically interested in FPS for Canvas animations.
http://weblogs.mozillazine.org/roc/archives/2010/11/measuring_fps.html will tell you that trying to measure framerate by counting how often your setTimeout runs is not accurate. The browser can run your Timeout callback multiple times between screen paints.
Turns out Mozilla has a window.mozPaintCount https://developer.mozilla.org/en/DOM/window.mozPaintCount available, which should provide an accurate FPS. However, this only works for Mozilla.
There's an open issue for Chrome for something similar: http://code.google.com/p/chromium/issues/detail?id=65348
A manual way to check for hardware accelerated FPS in Chrome is to grab the Chrome Beta channel (as of posting date) and go to about:flags and turn on FPS Counter. However, on a Mac, acceleration only turns on when using WebGL. So, no way to check FPS for Canvas on Chrome for Mac.
What are other strategies for accurately measuring HTML5 FPS?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请检查:
https://github.com/mrdoob/stats.js - 这是我所知道的最好的 FPS 显示器。它还为您提供一些有关内存/CPU 使用情况的统计信息(您必须使用特殊参数运行浏览器才能公开该数据),但也可能会受到您所描述的不准确的影响。
https://github.com/pcwalton/firefox-framerate-monitor< /p>
另外,在新的 chrome 版本(可能是金丝雀流)中,应该有一个在
about:flags
中显示 FPS 的选项。Please check:
https://github.com/mrdoob/stats.js - it's the best FPS monitor I know. It also gives you some stats about mem/cpu usage (you have to run your browser with special parameter to expose that data), but may also suffer from the inaccuracy you described.
https://github.com/pcwalton/firefox-framerate-monitor
Also, in new chrome builds (probably canary stream) there should be an option for displaying FPS in
about:flags
.