pub struct PhaseTimer { /* private fields */ }Expand description
Lightweight sub-phase timer for hot-path instrumentation.
Zero overhead when disabled (all methods are no-ops).
When enabled, captures phase boundaries via mark() and
emits structured timing via emit().
Implementations§
Source§impl PhaseTimer
impl PhaseTimer
Sourcepub fn from_env(env_var: &'static str, label: &'static str) -> Self
pub fn from_env(env_var: &'static str, label: &'static str) -> Self
Create a timer controlled by an environment variable.
Returns a disabled (zero-cost) timer if the env var is unset or != “1”.
Sourcepub fn mark(&mut self, phase: &'static str)
pub fn mark(&mut self, phase: &'static str)
Mark the end of a named phase. The duration is from the previous mark (or start) to now.
Sourcepub fn emit(&self, iteration: u64, batch_size: usize)
pub fn emit(&self, iteration: u64, batch_size: usize)
Emit timing data if enabled and the iteration matches the emit interval.
Default interval: first 5 iterations, then every 100.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if the timer is enabled.
Auto Trait Implementations§
impl Freeze for PhaseTimer
impl RefUnwindSafe for PhaseTimer
impl Send for PhaseTimer
impl Sync for PhaseTimer
impl Unpin for PhaseTimer
impl UnsafeUnpin for PhaseTimer
impl UnwindSafe for PhaseTimer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more