Skip to main content

Module perf

Module perf 

Source
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§

PerfSnapshot
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: if SUI_EVAL_PERF is NOT set we leave the flag as-is rather than clearing it, so that a prior set_enabled(true) (from a profiling tool or integration test) survives the next eval() 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 perf subcommand that wants counters even when SUI_EVAL_PERF=1 isn’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).