简体   繁体   English

对基于Web的动画的FPS进行基准测试?

[英]Benchmarking FPS for web-based animation?

I'm looking to write a simple frames per second animation benchmark Javascript utility. 我正在寻找编写每秒简单帧的动画基准Javascript实用程序。 FPS is probably a lose term here, but ideally something that will let me more accurately compare and measure how different animations (CSS3/canvas/webgl) are performing between browsers and devices. FPS在这里可能是个输家,但理想情况下,它可以让我更准确地比较和衡量浏览器和设备之间不同动画(CSS3 / canvas / webgl)的表现方式。 (so not something that just tests specific code - but a JS library thats included in the page and able to do its thing on its own) (所以不是只测试特定代码的东西-而是页面中包含的JS库,并且能够自行执行此操作)

And am looking for ideas on how to best approach the subject. 并且我正在寻找有关如何最好地解决该问题的想法。

For example I'm hoping that requestAnimationFrame is what I'm looking for - I've been reading about it a bit and it seems that its called every time the browser is available to redraw/animate something right? 例如,我希望requestAnimationFrame是我正在寻找的东西-我已经阅读了一些,似乎每次浏览器可用于重绘/设置动画时,它都会被调用? So by the same logic if (when running an animation) the browser is not available as often (as often as for example in a blank run) - we already have some numbers that we could compare agains right there. 因此,按照相同的逻辑,如果(运行动画时)浏览器不经常(例如在空运行中)不可用-我们已经有了一些可以在此处进行比较的数字。

The problem is of course requestAnimationFrame is not supported as widely as I'd like (especially on mobile). 问题是当然不像我想要的那样广泛支持requestAnimationFrame(尤其是在移动设备上)。 Could setInterval be used there somehow? 可以以某种方式使用setInterval吗? I understand its not as reliable but maybe that could be used to my advantage - for example if I call it 1000 times per second and then compare that agains how many times it was really executed per second - that's already a benchmark of a sort. 我知道它不是那么可靠,但是也许可以发挥我的优势-例如,如果我每秒调用它1000次,然后再次将其每秒实际执行多少次进行比较-这已经是一种基准。

The only issue here is that that method would give back measurements for any number of issues, not just animation - for example I can imagine the browser skipping an interval because its doing something in the DOM, etc. etc. You might argue that a browser is a single-process animal so DOM alterations affect animation too - but is that still true if for example a CSS3 animation is GPU hardware accelerated? 这里唯一的问题是该方法将返回任意数量的问题的度量值,而不仅仅是动画-例如,我可以想象浏览器跳过一个间隔,因为它在DOM中做某事,等等。您可能会争辩说浏览器是单进程动物,因此DOM更改也会影响动画-但是,例如CSS3动画是否由GPU硬件加速,这仍然适用吗?

Just a theory at the moment - so any ideas are much appreciated! 目前仅是一种理论-因此非常感谢任何想法! ;-) ;-)

看起来它应该很容易适应一组可以在您的特定情况下使用的功能(“做自己的事”): https : //gist.github.com/1156092

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM