简体   繁体   English

在DevTools中读取Chrome帧速率结果

[英]Reading Chrome Frame Rate results in DevTools

As far as I know the white (empty) bar represents idle time. 据我所知,白色(空)条表示空闲时间。 I know I should focus so that the application would run (at best) > 60fps and at least >30fps 我知道我应该专注于使应用程序运行(最好)> 60fps,至少> 30fps

This is my bar: 这是我的酒吧: 在此处输入图片说明

As you can see, I'm repainting on scroll ( changing the background position of an image ). 如您所见,我正在滚动绘制(更改图像的背景位置)。 The middle line marks 60fps in this case, and if you pay attention closely, there is a top line (which is 30fps). 在这种情况下,中间一行标记为60fps,如果您密切注意,则会有一个第一行(30fps)。

I've compared my results with others out there, and it seems that I have rather large idle times. 我已经将自己的结果与其他人的结果进行了比较,似乎我有很多空闲时间。 Is that okay ? 这样可以吗 ? I know that paint, javascript and anything else is bad, but what purpose does displaying idle times serve ? 我知道绘画,JavaScript和其他任何东西都不好,但是显示空闲时间有什么目的呢? Should I attempt to get rid of it, if so, what should I watch out for ? 我应该尝试摆脱它吗,如果是这样,我应该注意什么?

Also, there is a spike every now and then because of "Image Decode", is there anything I can do about it ? 另外,由于“图像解码”,有时会出现尖峰,对此我能做些什么?

Image Decode 图像解码

You can reduce the size of the image, which will make the decodes shorter. 您可以减小图像的尺寸,这将缩短解码时间。 You can also trick the browser into doing these decodes earlier, perhaps at a time when there's no activity and therefore won't hurt your FPS. 您还可以诱使浏览器更早地进行这些解码,也许是在没有活动的时候进行,因此不会损害您的FPS。

I would also kill these big images temporarily to see if that moves you from 30fps to 60fps. 我还将暂时杀死这些大图像,看看是否能将您从30fps移至60fps。

Scroll handler 滚动处理程序

You should minimize the amount of work you're doing in your scroll handler. 您应该将滚动处理程序中的工作量减至最少。 At most you should be grabbing one scroll metric from the DOM and a timestamp perhaps. 最多,您应该从DOM中获取一个滚动指标和一个时间戳。 Then do your adjustments to style in a requestAnimationFrame loop: http://www.hesslerdesign.com/blog/javascript/optimizing-javascript-performance-handling-coordinate-updates/ 然后在requestAnimationFrame循环中对样式进行调整: http : //www.hesslerdesign.com/blog/javascript/optimizing-javascript-performance-handling-coordinate-updates/

Heavy paints 重油漆

background-position isn't optimized well in WebKit or Blink, especially for this sort of usecase. 在WebKit或Blink中, background-position的优化不是很好,特别是对于这种用例。 I would put the image into a div and just slide its position using a transform: translate(x,y) (and promote it to its own layer if possible.) If sucessful, you won't repaint the entire screen on every scroll. 我将图像放入div,然后使用以下transform: translate(x,y)将其位置滑动transform: translate(x,y) (如果可能,将其提升到自己的图层。)如果成功,则不会在每个滚动上重新绘制整个屏幕。

30 FPS Aint bad 30 FPS不好

A solid 30FPS actually looks better than something that's jumping between 60 and 45 all the time. 稳定的30FPS实际上看起来比一直在60到45之间跳跃的更好。 Curious.. Are you in Canary or on a retina screen? 好奇..您在金丝雀中还是在视网膜屏幕上?


In general, you're doing pretty okay on your hardware, but I would try to reduce those image decodes. 通常,您在硬件上做的还不错,但我会尽量减少这些图像的解码。 And you can go further with the above if you want. 如果需要,您可以进一步讲解以上内容。

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

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