pub struct MemoryTracker { /* private fields */ }Expand description
Tracks memory usage over time with baseline, peak, and delta computation.
§Example
ⓘ
use fastapi_core::bench::MemoryTracker;
let mut tracker = MemoryTracker::new();
// ... do some work ...
tracker.sample();
// ... do more work ...
tracker.sample();
let report = tracker.report();
println!("{report}");Implementations§
Source§impl MemoryTracker
impl MemoryTracker
Sourcepub fn measure<F, R>(&mut self, f: F) -> Rwhere
F: FnOnce() -> R,
pub fn measure<F, R>(&mut self, f: F) -> Rwhere
F: FnOnce() -> R,
Record a sample while executing a closure, returning the closure’s result.
Sourcepub fn measure_repeated<F>(&mut self, iterations: usize, f: F)where
F: FnMut(),
pub fn measure_repeated<F>(&mut self, iterations: usize, f: F)where
F: FnMut(),
Record N iterations of a closure, sampling after each.
Sourcepub fn sample_count(&self) -> usize
pub fn sample_count(&self) -> usize
Number of samples taken (excluding baseline).
Sourcepub fn baseline(&self) -> MemorySnapshot
pub fn baseline(&self) -> MemorySnapshot
Get the baseline memory snapshot.
Sourcepub fn report(&self) -> MemoryReport
pub fn report(&self) -> MemoryReport
Generate a memory usage report.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MemoryTracker
impl RefUnwindSafe for MemoryTracker
impl Send for MemoryTracker
impl Sync for MemoryTracker
impl Unpin for MemoryTracker
impl UnwindSafe for MemoryTracker
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).