平铺图片大小对页面渲染速度的影响
如果背景图片是平铺的,图片文件的尺寸对页面渲染速度有影响吗?
我认为图像越小,填充目标区域所需执行的位块传输就越多,因此页面渲染所需的时间就越长[1]。 你认为这是真的吗?
我主要是从 iPhone(即 Mobile Safari)的角度来问问题,因为这就是我试图优化网站的目的。
[1] 如果确实如此,典型的“empty.gif”(1x1 透明图像)将是真正的性能杀手。
If a background image is tiled, do the dimensions of the image file have any influence on page rendering speed?
I imagine that the smaller the image, the more blits have to be performed to fill the target area, so the longer the page will take to render[1]. Do you suppose this is true?
I'm asking mostly from the perspective of the iPhone (so Mobile Safari), since that's what I'm trying to optimize a site for.
[1] If that is really the case, the typical "empty.gif" (1x1 transparent image) would be a real performance killer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在没有真正了解正在发生的情况或进行任何现场测试的情况下,不要进行任何性能优化。
使用小图像进行平铺时涉及的内存要少得多,因此 CPU 的缓存始终会被命中,这可能意味着更高的性能。
Don't do any performance optimization without really knowing what's going on or doing any field tests.
There's much less memory involved when tiling using a small image, so the CPU's cache is always hit, which could mean much higher performance.
虽然确实如此,但大多数渲染系统将能够相当快地渲染 1x1 像素的重复,因为它归结为:将
5000x5000 区域上平铺 50x50px 图像比在 100x100 区域上映射 1x1 像素图像的计算成本更高因为涉及到更多的数据。
我不会太担心机制,只需决定你是否可以足够快执行它
Althought true, most rendering systems will be able to render a repetition of 1x1 px fairly fast due to the fact that it boils down to:
It would be more computationally expensive to tile a 50x50px image over a 5000x5000 area than it would to map a 1x1 pixel image over a 100x100 area because there is more data involved.
I wouldn't worry too much about the mechanics, just decide if you can perform it fast enough
我不认为存在可测量的差异,至少只要我们不谈论 1000×1000 像素的图像。 但正如尼古拉所说,你必须衡量。 正是在这种情况下,没有什么比实验更好的了。
I do not think there is a measurable difference, at least as long as we are not talking about images 1000×1000 pixels. But as Nikolai said, you have to measure. This is exactly the case where nothing beats an experiment.