pub struct LatencyHistogram { /* private fields */ }Expand description
Collects latency samples and computes percentile statistics.
Samples are stored unsorted for fast insertion. Sorting happens lazily when percentiles or reports are requested.
Implementations§
Source§impl LatencyHistogram
impl LatencyHistogram
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a histogram pre-allocated for the given capacity.
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 latency by measuring the duration of a closure.
Sourcepub fn percentile(&mut self, p: f64) -> Option<Duration>
pub fn percentile(&mut self, p: f64) -> Option<Duration>
Compute the value at the given percentile (0.0 to 100.0).
Returns None if no samples have been recorded.
Uses nearest-rank method for percentile computation.
Sourcepub fn report(&mut self) -> Option<LatencyReport>
pub fn report(&mut self) -> Option<LatencyReport>
Generate a full latency report with all standard percentiles.
Sourcepub fn histogram_buckets(&mut self, num_buckets: usize) -> Vec<HistogramBucket>
pub fn histogram_buckets(&mut self, num_buckets: usize) -> Vec<HistogramBucket>
Build histogram buckets with the specified number of bins.
Returns a list of (bucket_start, bucket_end, count) tuples.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LatencyHistogram
impl RefUnwindSafe for LatencyHistogram
impl Send for LatencyHistogram
impl Sync for LatencyHistogram
impl Unpin for LatencyHistogram
impl UnwindSafe for LatencyHistogram
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).