Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to set custom CPU throttling in Chrome DevTools?

Tags:

I am using Google Chrome 63.

In DevTools in Performance tab there are three CPU throttling settings: "No throttling", "4x slowdown" and "6x slowdown".

Is it possible to set custom throttling, for example "20x slowdown"? It could be via setting some flag in chrome.exe file or programmatically via NodeJS library.

I found that Lighthouse library has kind of helpful function but if I change the default value inside it (CPU_THROTTLE_METRICS seems to be equal to 4) from 4 to (for example) 20 and run it, how can I be sure it really is 20x slowed down?

Also, I would like to know, if it is possible to do such simulated "slow down" to the GPU in similar way?

Thanks for any advice.

like image 377
Chris92 Avatar asked Feb 12 '18 17:02

Chris92


People also ask

How do I throttle my CPU in Chrome?

Open Chrome Canary or Developer and enter chrome://flags/#quick-intensive-throttling-after-loading in the address bar, as shown below. Set the 'Quick intensive throttling after loading' flag to Enabled and relaunch Chrome when prompted.

What is throttling in developer tools?

Network throttling enables a developer to emulate an experience of a user. Most browser developer tools, such as the browser inspector, provide a function to emulate different network conditions. By emulating your user's experience via network throttling, you can more readily identify and fix load time issues.

How do I use DevTools Performance tab in Chrome?

To access the Performance tab, navigate to the website you want to profile, then open Chrome DevTools by right-clicking and selecting Inspect. Select the Performance tab inside Chrome DevTools. The easiest way to capture a performance profile is by clicking the Start profiling and reload page icon.

What is network throttling profiles?

A profile to match regular download speeds, but slow upload speeds - as is the case with some ISPs around the world. A profile to match slow speeds and high latency, to simulate the experience for some people in rural areas.


1 Answers

Lighthouse uses Emulation.setCPUThrottlingRate command in the Chrome DevTools Protocol:

https://chromedevtools.github.io/devtools-protocol/tot/Emulation#method-setCPUThrottlingRate

You can monitor the protocol this way:

https://umaar.com/dev-tips/166-protocol-monitor/

You'll see this command in the protocol log when you switch with the throttling setting in the performance panel.

If you're asking how to be sure if it works - here is the implementation from Chromium source code:

https://github.com/chromium/chromium/blob/master/third_party/blink/renderer/platform/scheduler/util/thread_cpu_throttler.h#L21

// 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.

Hope this helps.

like image 197
Max Avatar answered Sep 19 '22 11:09

Max