Skip to main content

Histogram

Struct Histogram 

Source
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

Source

pub fn clear(&mut self)

Clears the instance, resetting all values to the equivalent of a newly constructed instance.

Source

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.

Source

pub fn push_event_time_ns(&mut self, time_in_ns: u64) -> bool

Pushes an event with the given number of nanoseconds.

Source

pub fn push_event_time_us(&mut self, time_in_us: u64) -> bool

Pushes an event with the given number of microseconds.

Source

pub fn push_event_time_ms(&mut self, time_in_ms: u64) -> bool

Pushes an event with the given number of milliseconds.

Source

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

Source

pub fn bucket_value(&self, index: usize) -> Option<u64>

Returns the count of events in a specific bucket.

Source

pub fn buckets(&self) -> &[u64; 64]

Returns a reference to all 64 buckets.

Source

pub fn event_count(&self) -> usize

Number of events counted.

Source

pub fn event_time_total(&self) -> Option<u64>

Returns the total event time in nanoseconds, if no overflow occurred.

Source

pub fn event_time_total_raw(&self) -> u64

Returns the total event time in nanoseconds, regardless of whether overflow has occurred.

Source

pub fn has_overflowed(&self) -> bool

Indicates whether overflow has occurred.

Source

pub fn min_event_time(&self) -> Option<u64>

Returns the minimum event time observed, if any.

Source

pub fn max_event_time(&self) -> Option<u64>

Returns the maximum event time observed, if any.

Source

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.0 for p50, 99.0 for 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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Histogram

Source§

fn clone(&self) -> Histogram

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Histogram

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Histogram

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.