pub struct Profiler {
pub enabled: bool,
pub events: Vec<(u64, ProfilingEvent)>,
pub call_stack: Vec<(String, u64)>,
}Expand description
Lightweight profiler that records events for later analysis.
Fields§
§enabled: boolWhether profiling is currently active.
events: Vec<(u64, ProfilingEvent)>Recorded events as (timestamp_ns, event) pairs.
call_stack: Vec<(String, u64)>Stack of (function_name, entry_timestamp_ns) entries.
Implementations§
Source§impl Profiler
impl Profiler
Sourcepub fn record(&mut self, event: ProfilingEvent)
pub fn record(&mut self, event: ProfilingEvent)
Record an arbitrary profiling event (no-op when disabled).
Sourcepub fn enter_function(&mut self, name: &str)
pub fn enter_function(&mut self, name: &str)
Record a function entry and push it onto the call stack.
Sourcepub fn exit_function(&mut self, name: &str)
pub fn exit_function(&mut self, name: &str)
Record a function exit and pop it from the call stack.
Sourcepub fn generate_report(&self) -> ProfileReport
pub fn generate_report(&self) -> ProfileReport
Generate a report from the recorded events.
Sourcepub fn memory_profile(&self) -> MemoryProfile
pub fn memory_profile(&self) -> MemoryProfile
Generate a memory profile from the recorded events.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Profiler
impl RefUnwindSafe for Profiler
impl Send for Profiler
impl Sync for Profiler
impl Unpin for Profiler
impl UnsafeUnpin for Profiler
impl UnwindSafe for Profiler
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