pub struct Histogram { /* private fields */ }Expand description
Low-cost performance percentile histogram using 64-buckets.
§Note:
This histogram tracks event durations with nanosecond precision across 64 logarithmic power-of-two spacing buckets. This is extremely efficient and suited for high-frequency low-overhead timing measurements.
Implementations§
Source§impl Histogram
impl Histogram
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears the instance, resetting all values to the equivalent of a newly constructed instance.
Sourcepub fn push_event_duration(&mut self, duration: Duration) -> bool
pub fn push_event_duration(&mut self, duration: Duration) -> bool
Pushes an event with the given std_time::Duration.
§Note:
The value obtained from Duration#as_nanos() is truncated to
u64.
Sourcepub fn push_event_time_ns(&mut self, time_in_ns: u64) -> bool
pub fn push_event_time_ns(&mut self, time_in_ns: u64) -> bool
Pushes an event with the given number of nanoseconds.
Sourcepub fn push_event_time_us(&mut self, time_in_us: u64) -> bool
pub fn push_event_time_us(&mut self, time_in_us: u64) -> bool
Pushes an event with the given number of microseconds.
Sourcepub fn push_event_time_ms(&mut self, time_in_ms: u64) -> bool
pub fn push_event_time_ms(&mut self, time_in_ms: u64) -> bool
Pushes an event with the given number of milliseconds.
Sourcepub fn push_event_time_s(&mut self, time_in_s: u64) -> bool
pub fn push_event_time_s(&mut self, time_in_s: u64) -> bool
Pushes an event with the given number of seconds.
Source§impl Histogram
impl Histogram
Sourcepub fn bucket_value(&self, index: usize) -> Option<u64>
pub fn bucket_value(&self, index: usize) -> Option<u64>
Returns the count of events in a specific bucket.
Sourcepub fn event_count(&self) -> usize
pub fn event_count(&self) -> usize
Number of events counted.
Sourcepub fn event_time_total(&self) -> Option<u64>
pub fn event_time_total(&self) -> Option<u64>
Returns the total event time in nanoseconds, if no overflow occurred.
Sourcepub fn event_time_total_raw(&self) -> u64
pub fn event_time_total_raw(&self) -> u64
Returns the total event time in nanoseconds, regardless of whether overflow has occurred.
Sourcepub fn has_overflowed(&self) -> bool
pub fn has_overflowed(&self) -> bool
Indicates whether overflow has occurred.
Sourcepub fn min_event_time(&self) -> Option<u64>
pub fn min_event_time(&self) -> Option<u64>
Returns the minimum event time observed, if any.
Sourcepub fn max_event_time(&self) -> Option<u64>
pub fn max_event_time(&self) -> Option<u64>
Returns the maximum event time observed, if any.
Sourcepub fn value_at_percentile(&self, percentile: f64) -> Option<u64>
pub fn value_at_percentile(&self, percentile: f64) -> Option<u64>
Returns the approximated duration (in nanoseconds) at the given percentile.
§Parameters
percentile: A float value representing the desired percentile (e.g.,50.0for p50,99.0for p99); value is clamped to the range[0.0, 100.0];
§Return
Returns Some(value_in_ns) if the histogram contains one or more
events; otherwise, returns None.
Sourcepub fn value_at_p50(&self) -> Option<u64>
pub fn value_at_p50(&self) -> Option<u64>
Returns the approximated duration (in nanoseconds) at the 50th percentile (p50).
§Return
Returns Some(value_in_ns) if the histogram contains one or more
events; otherwise, returns None.
Sourcepub fn value_at_p75(&self) -> Option<u64>
pub fn value_at_p75(&self) -> Option<u64>
Returns the approximated duration (in nanoseconds) at the 75th percentile (p75).
§Return
Returns Some(value_in_ns) if the histogram contains one or more
events; otherwise, returns None.
Sourcepub fn value_at_p90(&self) -> Option<u64>
pub fn value_at_p90(&self) -> Option<u64>
Returns the approximated duration (in nanoseconds) at the 90th percentile (p90).
§Return
Returns Some(value_in_ns) if the histogram contains one or more
events; otherwise, returns None.
Sourcepub fn value_at_p95(&self) -> Option<u64>
pub fn value_at_p95(&self) -> Option<u64>
Returns the approximated duration (in nanoseconds) at the 95th percentile (p95).
§Return
Returns Some(value_in_ns) if the histogram contains one or more
events; otherwise, returns None.
Sourcepub fn value_at_p99(&self) -> Option<u64>
pub fn value_at_p99(&self) -> Option<u64>
Returns the approximated duration (in nanoseconds) at the 99th percentile (p99).
§Return
Returns Some(value_in_ns) if the histogram contains one or more
events; otherwise, returns None.
Sourcepub fn value_at_p99_5(&self) -> Option<u64>
pub fn value_at_p99_5(&self) -> Option<u64>
Returns the approximated duration (in nanoseconds) at the 99.5th percentile (p99.5).
§Return
Returns Some(value_in_ns) if the histogram contains one or more
events; otherwise, returns None.
Sourcepub fn value_at_p99_9(&self) -> Option<u64>
pub fn value_at_p99_9(&self) -> Option<u64>
Returns the approximated duration (in nanoseconds) at the 99.9th percentile (p99.9).
§Return
Returns Some(value_in_ns) if the histogram contains one or more
events; otherwise, returns None.
Sourcepub fn value_at_p99_99(&self) -> Option<u64>
pub fn value_at_p99_99(&self) -> Option<u64>
Returns the approximated duration (in nanoseconds) at the 99.99th percentile (p99.99).
§Return
Returns Some(value_in_ns) if the histogram contains one or more
events; otherwise, returns None.
Sourcepub fn value_at_p99_999(&self) -> Option<u64>
pub fn value_at_p99_999(&self) -> Option<u64>
Returns the approximated duration (in nanoseconds) at the 99.999th percentile (p99.999).
§Return
Returns Some(value_in_ns) if the histogram contains one or more
events; otherwise, returns None.
Sourcepub fn value_at_p99_999_9(&self) -> Option<u64>
pub fn value_at_p99_999_9(&self) -> Option<u64>
Returns the approximated duration (in nanoseconds) at the 99.9999th percentile (p99.9999).
§Return
Returns Some(value_in_ns) if the histogram contains one or more
events; otherwise, returns None.