throttle cpu and network conditions in puppeteer using a cdpsession for performance testing

domain: pptr.dev · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. create a CDP session with await page.target().createCDPSession() (or the higher-level page.createCDPSession() depending on the installed version)
  2. send client.send('Network.enable') followed by client.send('Network.emulateNetworkConditions', { offline: false, downloadThroughput, uploadThroughput, latency }) to simulate a constrained connection such as slow 3G
  3. send client.send('Emulation.setCPUThrottlingRate', { rate: 4 }) to simulate a CPU roughly four times slower than the test machine
  4. run the page interaction or navigation under test and measure timing metrics (e.g. via the Performance API or Lighthouse-style metrics) under the throttled conditions
  5. reset throttling (rate: 1, and network conditions back to unrestricted) at the end of the test so it does not leak into subsequent tests sharing the same page or context

Known gotchas

Related routes

Create isolated Puppeteer browser contexts with browser.createBrowserContext() for parallel sessions
pptr.dev · 5 steps · unrated
Send raw Chrome DevTools Protocol commands via a CDPSession in Puppeteer
pptr.dev · 6 steps · unrated
enable and configure headless chrome downloads in puppeteer using cdp page.setdownloadbehavior
pptr.dev · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans