pub struct PerfCollector { /* private fields */ }Implementations§
Source§impl PerfCollector
impl PerfCollector
pub fn new() -> Self
Sourcepub fn start_timer(&self, category: &str, name: &str) -> impl FnOnce() -> f64
pub fn start_timer(&self, category: &str, name: &str) -> impl FnOnce() -> f64
Start a timer and return a closure that stops it and records the value.
Sourcepub fn checkpoint(&self, name: &str) -> f64
pub fn checkpoint(&self, name: &str) -> f64
Record the elapsed time since collector creation as a named checkpoint.
Returns the elapsed milliseconds since Self was created.
§Example
let perf = PerfCollector::new();
// ... phase 1 ...
let t1 = perf.checkpoint("config_loaded");
// ... phase 2 ...
let t2 = perf.checkpoint("skills_scanned");Sourcepub fn elapsed_ms(&self) -> f64
pub fn elapsed_ms(&self) -> f64
Return the time elapsed since collector creation in milliseconds.
Sourcepub fn checkpoint_snapshot(&self) -> Vec<(String, f64)>
pub fn checkpoint_snapshot(&self) -> Vec<(String, f64)>
Return a snapshot of all startup checkpoint timings.
Returns a Vec of (checkpoint_name, elapsed_ms) pairs sorted by elapsed time.
Sourcepub fn stats(&self, category: &str, name: &str) -> Option<MetricStats>
pub fn stats(&self, category: &str, name: &str) -> Option<MetricStats>
Compute stats for a given metric key.
pub fn p95(&self, category: &str, name: &str) -> Option<f64>
Trait Implementations§
Source§impl Clone for PerfCollector
impl Clone for PerfCollector
Source§impl Debug for PerfCollector
impl Debug for PerfCollector
Auto Trait Implementations§
impl Forget for PerfCollector
impl Freeze for PerfCollector
impl Move for PerfCollector
impl RefUnwindSafe for PerfCollector
impl Send for PerfCollector
impl Sync for PerfCollector
impl Unpin for PerfCollector
impl UnsafeUnpin for PerfCollectorwhere
*const ArcInner<RwLock<HashMap<String, Vec<f64>>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<RwLock<HashMap<String, Vec<f64>>>>>: UnsafeUnpin,
impl UnwindSafe for PerfCollector
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