pub struct PerfSnapshot {
pub elapsed: Option<Duration>,
pub counters: [u64; 56],
pub thunks_created: u64,
pub thunks_forced: u64,
}Expand description
An immutable snapshot of counter + timer state at a single point.
Cheap to clone (just a fixed-size array + a few u64). Subtract two
snapshots (b.delta_from(&a)) to get the work done between them —
the foundation of with_scope and per-program profiling.
Fields§
§elapsed: Option<Duration>Wall-clock elapsed since start was called. None if start
wasn’t called in this thread.
counters: [u64; 56]Raw counter values, indexed by Counter as usize.
thunks_created: u64Thunks allocated in this thread to date (from trace module).
thunks_forced: u64Thunks forced (from suspended → evaluated) to date.
Implementations§
Source§impl PerfSnapshot
impl PerfSnapshot
Sourcepub fn delta_from(&self, other: &PerfSnapshot) -> PerfSnapshot
pub fn delta_from(&self, other: &PerfSnapshot) -> PerfSnapshot
self - other, treating both as counter totals. Used to get
the delta across a scoped evaluation (snapshot before, snapshot
after, subtract). Saturates to zero on underflow — shouldn’t
happen in normal use but guards against races / manual resets.
Sourcepub fn thunk_hit_rate(&self) -> Option<f64>
pub fn thunk_hit_rate(&self) -> Option<f64>
Thunk memoization hit rate — 1.0 means every suspended thunk
produced useful work; 0.0 means everything we built was wasted.
Returns None when no thunks were created in this window.
Sourcepub fn dominant_expr_kind(&self) -> Option<(Counter, u64)>
pub fn dominant_expr_kind(&self) -> Option<(Counter, u64)>
(top_variant, count) — the expression kind with the highest
count in this snapshot. For ranking “what is this eval mostly
doing?” at a glance.
Trait Implementations§
Source§impl Clone for PerfSnapshot
impl Clone for PerfSnapshot
Source§fn clone(&self) -> PerfSnapshot
fn clone(&self) -> PerfSnapshot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for PerfSnapshot
impl RefUnwindSafe for PerfSnapshot
impl Send for PerfSnapshot
impl Sync for PerfSnapshot
impl Unpin for PerfSnapshot
impl UnsafeUnpin for PerfSnapshot
impl UnwindSafe for PerfSnapshot
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.