Measurement on cpu time

Is there any way to measure cpu time? Since Date.now() doesn't work as it mentioned in this wiki https://developers.cloudflare.com/workers/runtime-apis/performance My worker is run heavily on cpu with wasm like processing image , measure only database fetches or api fetches is not enough for request tracing, didn't give me enough info to visual the request timeline
Cloudflare Docs
Performance and timers · Cloudflare Workers docs
Measure timing, performance, and timing of subrequests and other operations.
6 Replies
Chaika
Chaika6mo ago
In local development, however, timers will increment regardless of whether I/O happens or not. This means that if you need to measure timing of a piece of code that is CPU intensive, that does not involve I/O, you can run your Worker locally, via Wrangler, which uses the open-source Workers runtime, workerd — the same runtime that your Worker runs in when deployed to Cloudflare.
best you can do right now for exact timing of specific functions
an
an6mo ago
best you can do right now for exact timing of specific functions
@Chaika what does specific functions mean, does it mean worker or a function like abc() if abc(), is there any doc for it?
Chaika
Chaika6mo ago
I mean that in local, you can use Date.now and Performance. now as normal, and they will function normally it's only on deployed workers that they are frozen except for i/o and local uses workerd/the same runtime as deployed (although of course different cpu and such), you can still get rough numbers "ok this is super inefficient method", etc
an
an6mo ago
ah I'm using it to observability and building dashboard to see numbers. it's so bad when we can't take that number but I understand your point, thank for answer, hope we can measure it one day
an
an6mo ago
@Chaika can https://developers.cloudflare.com/workers/runtime-apis/rpc/ work for this, like measure rpc instead
Cloudflare Docs
Remote-procedure call (RPC) · Cloudflare Workers docs
The built-in, JavaScript-native RPC system built into Workers and Durable Objects.
an
an6mo ago
just tested and it seem like pretty the same as before, I think normal fetch would be fine, will update soon
Want results from more Discord servers?
Add your server