Skip to main content

Module cpu_probe

Module cpu_probe 

Source
Expand description

Lightweight CPU timing spans, drained per frame by the preview profiler panel. Lightweight CPU timing spans, mirroring crate::upload_probe and the GPU timer scopes: leaf-level named spans recorded into a thread-local buffer, drained once per frame by the consumer (the preview profiler panel).

Spans are always recorded (a span costs two Instant::now reads, ~50ns) and are leaf-level only โ€” never nest them, so the frame total is the sum of all spans without double counting. If nobody drains the buffer (e.g. the CLI render worker thread), it self-clears at a span cap so memory stays bounded.

Structsยง

Span
A scoped CPU timing span. Records (label, ms) into the thread-local frame buffer when dropped.

Constantsยง

MAX_SPANS ๐Ÿ”’
Upper bound on buffered spans; exceeding it clears the buffer (the consumer is expected to drain every frame).
SPANS ๐Ÿ”’

Functionsยง

span
Start a named leaf-level CPU span (records on scope exit):
take_frame
Drain the spans recorded on this thread since the last call.