[英]LCP time between LightHouse and Performance - Google Chrome
With google chrome chrome dev, I am running a lighthouse Analysis for mobile.使用 google chrome chrome dev,我正在为移动设备运行灯塔分析。
Lighthouse shows a 7.0 seconds delay for Largest Contentful Paint (LCP): Lighthouse 显示最大内容绘制 (LCP) 的延迟为 7.0 秒:
I decide to dive into this and click on: "View original trace".我决定深入研究并单击:“查看原始跟踪”。
It redirects me to the Performance tabs:它将我重定向到性能选项卡:
Here it says that the LCP is 749.7ms (= 0.7497 seconds).这里说 LCP 是 749.7 毫秒(= 0.7497 秒)。
Where this discrepancy between LightHouse and Performance tab comes from? LightHouse 和 Performance 选项卡之间的这种差异来自哪里?
The answer is a combination of simulated network throttling and CPU throttling .答案是模拟网络节流和CPU 节流的组合。
When you run an audit it applies 150ms latency to each request and also limits download speed to 1.6 Megabits (200 kilobytes) per second and upload to 750 megabits (94 kilobytes) per second.当您运行审核时,它会对每个请求应用 150 毫秒的延迟,并将下载速度限制为每秒 1.6 兆位(200 千字节),上传速度为每秒 750 兆位(94 千字节)。
This is done via an algorithm rather than applied (it is simulated)这是通过算法而不是应用来完成的(它是模拟的)
Lighthouse applies a 4x slowdown to your CPU to simulate a mid-tier mobile phone performance. Lighthouse 对您的 CPU 应用 4 倍减速以模拟中端手机性能。
If your JavaScript payload is heavy this could block the main thread and delay rendering.如果您的 JavaScript 负载很重,这可能会阻塞主线程并延迟渲染。 Or if you dynamically insert elements using JavaScript it can delay LCP for the same reason.
或者,如果您使用 JavaScript 动态插入元素,出于同样的原因,它可能会延迟 LCP。
This is also done via an algorithm rather than applied (it is simulated)这也是通过算法而不是应用来完成的(它是模拟的)
Because the trace is "as it happened" and doesn't take into account the simulated network and CPU slowdown.因为跟踪是“正如它发生的那样”,并且没有考虑模拟的网络和 CPU 减速。
Yes - all you need to do is uncheck "Simulated throttling" under the settings section (you may need to press the cog in the top right of the Lighthouse tab to show this checkbox).是的 - 您需要做的就是取消选中设置部分下的“模拟节流”(您可能需要按下 Lighthouse 选项卡右上角的齿轮以显示此复选框)。
Be aware that you will probably get an even lower score as simulated throttling can be a bit more forgiving.请注意,您可能会得到更低的分数,因为模拟节流可能会更宽容一些。
Also note that your report will take a lot longer to run (which is good for seeing how someone on a slow phone with a slow 4G connection might experience your site!)另请注意,您的报告将花费更长的时间来运行(这有助于了解使用 4G 连接速度较慢的手机的人可能会如何体验您的网站!)
Now when you run Lighthouse it will use applied throttling, adding the latency and CPU slowdown in real time.现在,当您运行 Lighthouse 时,它将使用应用节流,实时添加延迟和 CPU 减速。 If you view your trace now you will see it matches.
如果您现在查看您的跟踪,您将看到它匹配。
At the bottom of your report you can see what settings were applied.在报告底部,您可以看到应用了哪些设置。 You will see on the screenshot below that "(Devtools)" is listed in the Network Throttling and the CPU throttling sections to show that I use applied throttling.
您将在下面的屏幕截图中看到“(Devtools)”列在网络节流和 CPU 节流部分,以表明我使用了应用节流。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.