检查系统是否能流畅显示JS效果
我想知道是否有一种简单的方法可以在浏览器上实现渲染速度的快速基准测试?
拥有漂亮的动画效果固然很好,但前提是机器能够处理它。借助 SVG 和 jQuery 为大众提供的所有效果,可以以可视化和动画方式显示大量数据。然而,没有简单的方法(我还可以找到)来检查并查看用户代理是否应该传递“华丽的动画 svg”、“静态 svg”或“表格”版本的数据。
谢谢
I am wondering if there's an easy way to implement a quick benchmark on a browser for rendering speed?
It is nice to have spiffy animation effects, but only if the machine can handle it. With SVG and all the effects jQuery has given the masses there is the possibility of displaying large amounts of data visually, and animated. However, there's no simple way (that I can find yet) to check and see if the user-agent should be delivered the 'flashy animated svg', 'static svg' or 'tabled' version of the data.
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我知道执行此操作的唯一方法是实际运行代表性动画并测量其速度,无论是渲染 x 帧的时间还是每个固定时间的总帧数。 jQuery 和 YUI 中的动画库根据渲染每个帧的速度来调整渲染的帧数。您可以看看他们是如何做到这一点的,以获得一些如何衡量这一点的想法,或者如果您正在使用这些库之一,您甚至可以在动画之后从它们中获取信息。
您可以运行此测试动画,然后对结果进行 cookie,然后仅在找不到 cookie 时重新运行测试动画。或者,您可以在应用程序的正常过程中运行所需的动画,但测量它的工作效果,如果它太慢或不稳定,那么下次您需要使用更快的动画。
The only way I know of do this is to actually run a representative animation and measure it's speed, either in time to render x frames or in total frames per fixed time. The animation libraries in both jQuery and YUI adapt the number of frames that they render based on the speed of rendering each frame as they go. You can look at how they do that to get some ideas how to measure this or if you're using one of those libraries, you may even be able to get the info out of them after an animation.
You could run this test animation and then cookie the result and then only rerun the test animation when you don't find the cookie. Or, you could run the desired animation in the normal course of your app, but measure how well it worked and if it was too slow or jerky, then cookie that you need to use something quicker next time.
尝试使用 Firebug 中的“网络”选项卡。只需加载要测试的页面,打开 Firebug,单击“网络”选项卡中的小向下箭头并选择“启用”,然后刷新页面。您会得到页面上每个元素的加载时间的漂亮图表。
Try using the Net tab in Firebug. Just load the page you want to test, open Firebug, click the little down arrow in the Net tab and select Enable, then refresh your page. You get pretty graphs of the loading times of each element on the page.
我之前已经使用 Enhance.js 来执行此操作,
请看一下加载 css 和的示例专门用于屏幕和移动设备的
Node.jsEnhance.js 还具有其他类型的检查,如果需要,您还可以添加或拥有自定义检查
灯丝组页面,还有更多相关内容
I have used Enhance.js to do this before
Take a look at an example of loading css and js exclusively for screen and mobile devices
Enhance.js also have other types of checks, and you can also add or own custom check, if necessary
On Filament Group page, there's more about it