简体   繁体   English

LightHouse 和 Performance 之间的 LCP 时间 - Google Chrome

[英]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 选项卡之间的这种差异来自哪里?

  • 0.7497 seconds for Performance 0.7497 秒的性能
  • 7.0 seconds for LightHouse LightHouse 7.0 秒

Why is Lighthouse showing much longer load times?为什么 Lighthouse 显示加载时间更长?

The answer is a combination of simulated network throttling and CPU throttling .答案是模拟网络节流CPU 节流的组合。

Simulated Network Throttling模拟网络节流

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)这是通过算法而不是应用来完成的(它是模拟的)

CPU throttling CPU 节流

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)这也是通过算法而不是应用来完成的(它是模拟的)

So why doesn't it match the performance trace?那么为什么它与性能跟踪不匹配呢?

Because the trace is "as it happened" and doesn't take into account the simulated network and CPU slowdown.因为跟踪是“正如它发生的那样”,并且没有考虑模拟的网络和 CPU 减速。

Can I make the performance trace match Lighthouse?我可以让性能跟踪匹配 Lighthouse 吗?

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.如果您现在查看您的跟踪,您将看到它匹配。

Where can I see what settings were used on a run?我在哪里可以看到运行时使用了哪些设置?

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.

相关问题 Google Chrome Lighthouse性能得分为0 - Google Chrome Lighthouse performance score of 0 为什么在使用 Google Chrome Lighthouse 时会有未使用的图片资源? - Why are there unused images resources while using Google Chrome Lighthouse? Chrome - devtools时间线中的事件时间与性能计时API之间的差异 - Chrome - Difference between event time in devtools timeline and performance timing API 灯塔的 nuxt 表演 - nuxt performance in the lighthouse 性能工具(灯塔)在我的 Gatsby 网站上显示非常缓慢的“交互时间”。 我该如何改进它? - Performance tools (Lighthouse) show very slow “Time to Interactive” on my Gatsby site. How can I improve it? Chrome Lighthouse 是否因移动测试而损坏? - Is Chrome Lighthouse Broken for Mobile Testing? google lighthouse 如何计算 javascript 评估时间以及为什么它在不同环境中的相同脚本差异很大 - how google lighthouse calculates javascript evaluation time and why it varies by a huge margin for same scripts on different environments 在 Google Lighthouse 的 First Contentful Paint 报告中是否考虑了服务器响应时间? - Is server response time considered in First Contentful Paint report via Google Lighthouse? Google Chrome 性能:Linux 与 Windows - Google Chrome performance: Linux vs Windows Google Chrome Silverlight性能显着降低 - Google Chrome Silverlight Performance Is Significantly Slow
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM