Chr*_*s92 17 cpu throttling google-chrome-devtools
我使用的是Google Chrome 63.
在Performance选项卡的DevTools中,有三种CPU限制设置:" 无限制","4x减速"和"6x减速".
是否可以设置自定义限制,例如"20x减速"?它可以通过在chrome.exe文件中设置一些标志或通过NodeJS库以编程方式设置.
我发现Lighthouse库有一些有用的功能,但如果我将其中的默认值(CPU_THROTTLE_METRICS似乎等于4)从4更改为(例如)20并运行它,我怎么能确定它真的是20x减速下?
另外,我想知道,如果有可能以类似的方式对GPU进行模拟"减速"吗?
谢谢你的建议.
she*_*erb 12
可以在 Chrome 中直接设置自定义值Emulation.setCPUThrottlingRate,但您需要在开发工具窗口上打开开发工具窗口才能以编程方式更改设置。
let Main = await import('./devtools-frontend/front_end/entrypoints/main/main.js');
await Main.MainImpl.sendOverProtocol('Emulation.setCPUThrottlingRate', {rate: 40});
Run Code Online (Sandbox Code Playgroud)
此示例将使 Chrome 性能降低 40 倍。注意:传递 1 将rate关闭节流。
在创建第二个开发工具窗口后,步骤 1 中创建的第一个开发工具窗口可能会重新停靠。
Lighthouse 使用Emulation.setCPUThrottlingRateChrome DevTools 协议中的命令:
https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setCPUThrotdlingRate
您可以通过以下方式监控协议:
https://umaar.com/dev-tips/166-protocol-monitor/
当您使用性能面板中的限制设置进行切换时,您将在协议日志中看到此命令。
如果您询问如何确定它是否有效 - 以下是 Chromium 源代码的实现:
// This class is used to slow down the main thread for // inspector "cpu throttling". It does it by spawning an // additional thread which frequently interrupts main thread // and sleeps.
希望这可以帮助。
| 归档时间: |
|
| 查看次数: |
3842 次 |
| 最近记录: |