Expand description
Lightweight evaluation profiling counters.
Lightweight evaluation profiling counters.
Enabled via SUI_EVAL_PERF=1 environment variable.
Uses enum-indexed array dispatch instead of string matching —
a single counts[variant as usize] += 1 per call, zero string
comparisons.
Structs§
- Perf
Snapshot - An immutable snapshot of counter + timer state at a single point.
Enums§
- Counter
- Performance counter identifiers.
Functions§
- add
- Increment the lookup depth accumulator by
depth. - counter_
name - Get the display name for a counter.
- enabled
- Whether profiling is enabled (fast atomic load).
- inc
- init
- Check the env var and, if set, enable counters. Called on every
top-level
eval(). Deliberately one-way: ifSUI_EVAL_PERFis NOT set we leave the flag as-is rather than clearing it, so that a priorset_enabled(true)(from a profiling tool or integration test) survives the nexteval()call. - report
- reset
- Zero every counter and restart the timer. The thread-local thunk trace counters are reset too.
- set_
enabled - Enable or disable perf counters programmatically. Use this from
profiling tools, integration tests, or the
sui perfsubcommand that wants counters even whenSUI_EVAL_PERF=1isn’t set in the environment. Production code paths don’t call this. - snapshot
- Capture the current counter state as a
PerfSnapshot. - start
- with_
scope - Scoped profiling: enable counters if they aren’t already, reset
them, run
f, and return(result, delta_snapshot).