平铺图片大小对页面渲染速度的影响

发布于 2024-07-25 21:28:19 字数 225 浏览 1 评论 0原文

如果背景图片是平铺的,图片文件的尺寸对页面渲染速度有影响吗?

我认为图像越小,填充目标区域所需执行的位块传输就越多,因此页面渲染所需的时间就越长[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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

苦妄 2024-08-01 21:28:19

在没有真正了解正在发生的情况或进行任何现场测试的情况下,不要进行任何性能优化。

使用小图像进行平铺时涉及的内存要少得多,因此 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.

熊抱啵儿 2024-08-01 21:28:19

虽然确实如此,但大多数渲染系统将能够相当快地渲染 1x1 像素的重复,因为它归结为:将

  1. 存储在内存/缓存中的值重复到另一个内存值
  2. ,或者对图形子系统进行操作(例如 OpenGL),它在 GPU 硬件(GDDR 或其他)的更快内存上进行此操作。在

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:

  1. Repetition of a value stored in memory/cache, to another memory value
  2. OR, operations on a graphics subsystem (such as OpenGL) which have operations for this on the faster memory of the GPU hardware (GDDR or whatver)

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

浅忆流年 2024-08-01 21:28:19

我不认为存在可测量的差异,至少只要我们不谈论 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文