Skip to content
Back to feed

November 23, 2026 · Cloudflare

Workers, Durable Objects - CPU and heap profiling for Worker Previews

You can now profile Worker Previews, following the launch of on-demand CPU and memory profiling ↗︎ for Workers and Durable Objects. This lets you see what a pull request costs in CPU and memory before you merge it.

Send traffic to a Preview, capture a CPU or heap profile from one of its deployments, and see which functions in your branch use the most CPU time or memory. Push a fix, profile the next deployment, and compare. Production stays untouched the whole time.

In this Preview, formatPrice takes almost a third of the CPU time because it creates a new Intl.NumberFormat for every product. A slowdown like this is easy to miss in code review, but it stands out in a flamegraph.

Let your agent optimize performance

Previews give coding agents a safe place to iterate on performance. An agent can deploy a Preview, send it load, capture a profile, rewrite the hottest function, and deploy again, until CPU time stops dropping. Each Preview deployment has its own ID, so every profile maps to an exact version of the code.

Copy promptPrompt copied!

Capture a profile with the Cloudflare CLI:

cf previews deployments profile latest \
  --worker my-worker \
  --preview my-preview \
  --duration-ms 5000 \
  --profile-type cpu > preview-cpu.pprof

Or with the API. Use latest to target the newest deployment of the Preview:

curl --request POST \
  "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/workers/workers/$WORKER_ID/previews/$PREVIEW_ID/deployments/latest/profile" \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{"duration_ms": 5000, "profile_type": "cpu"}' \
  --output preview-cpu.pprof.gz

Profile in the dashboard

Open your Preview, select Observability, and switch the view to Flamegraph. Choose a profile type and a Preview deployment, then select Capture profile. Explore the result as a flamegraph or table, or download the raw pprof file.

Profile Durable Objects on a Preview

Every Preview gets its own Durable Object namespaces. To see what one object is doing on your branch, profile it by ID, just like in production.

To get started, refer to Profile a Preview.

Get the week’s Cloudflare changes in one email

Free, every Monday: only what changed in Cloudflare that week. We email you a link to confirm.

See last week’s digest

Free. Unsubscribe any time.

All Workers changes