Created
January 11, 2024 09:44
-
-
Save hugoeanogueira/1bbd3251f3d169fc4901e4abcf640755 to your computer and use it in GitHub Desktop.
Configure Network and CPU throttling to Chrome using Playwright
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ENABLE THROTTLING IN CHROME WITH PLAYWRIGHT | |
// https://chromedevtools.github.io/devtools-protocol/tot/Network/#method-emulateNetworkConditions | |
// https://chromedevtools.github.io/devtools-protocol/tot/Emulation/#method-setCPUThrottlingRate | |
const cdpSession = await context.newCDPSession(page); | |
await cdpSession.send("Network.emulateNetworkConditions", { | |
downloadThroughput: 2_000_000 / 8, // 2 mbps | |
uploadThroughput: 2_000_000 / 8, // 2 mbps | |
latency: 100, // 100 ms | |
offline: false, | |
}); | |
await cdpSession.send("Emulation.setCPUThrottlingRate", { | |
rate: 2 // 2x cpu throttle | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment