pub struct SharedHistogram { /* private fields */ }Implementations§
Sourcepub fn create(
path: impl AsRef<Path>,
boundaries: &[u64],
) -> Result<Self, HistogramError>
pub fn create( path: impl AsRef<Path>, boundaries: &[u64], ) -> Result<Self, HistogramError>
Obtain the histogram at path, initializing empty buckets if
the path does not yet exist and attaching to it if it does.
Attaching leaves live counts in place; a region built with
different boundaries is a LayoutMismatch.
reset zeroes a live histogram in place.
pub fn open( path: impl AsRef<Path>, expected_boundaries: &[u64], ) -> Result<Self, HistogramError>
Sourcepub fn total_count(&self) -> u64
pub fn total_count(&self) -> u64
Total count across all buckets.
Sourcepub fn bucket_for(&self, value: u64) -> usize
pub fn bucket_for(&self, value: u64) -> usize
Find the bucket index for value. Binary search on boundaries.
Sourcepub fn record(&self, value: u64) -> usize
pub fn record(&self, value: u64) -> usize
Record one observation of value. Atomically increments the
matching bucket counter and the total. Returns the bucket
index it landed in.
Sourcepub fn count(&self, bucket_idx: usize) -> Result<u64, HistogramError>
pub fn count(&self, bucket_idx: usize) -> Result<u64, HistogramError>
Read a specific bucket’s count.
Sourcepub fn boundaries_vec(&self) -> Vec<u64>
pub fn boundaries_vec(&self) -> Vec<u64>
Get the boundaries vector (copy).
Sourcepub fn percentile(&self, p: f64) -> u64
pub fn percentile(&self, p: f64) -> u64
Estimate the p-th percentile (p in 0.0..=1.0). Walks buckets accumulating counts until p of total is covered, then linearly interpolates within the target bucket. Returns 0 if total is 0.
Sourcepub fn reset(&self)
pub fn reset(&self)
Reset all counters to 0. Not concurrency-coordinated; expect transient race with concurrent recorders.