Expand description
This crate provides histogram implementations that are conceptually similar to HdrHistogram, with modifications to the bucket construction and indexing algorithms that we believe provide a simpler implementation and more efficient runtime compared to the reference implementation of HdrHistogram.
§Types
Histogram— standard histogram withu64counters. Use for single-threaded recording and percentile queries.AtomicHistogram— atomic histogram for concurrent recording. Take a snapshot withAtomicHistogram::loadorAtomicHistogram::drainto query percentiles.SparseHistogram— compact representation storing only non-zero buckets. Useful for serialization and storage.
§Example
use histogram::Histogram;
let mut h = Histogram::new(7, 64).unwrap();
for value in 1..=100 {
h.increment(value).unwrap();
}
// Percentiles use the 0.0..=1.0 scale
let p50 = h.percentile(0.5).unwrap().unwrap();
let p99 = h.percentile(0.99).unwrap().unwrap();
// percentile() returns Result<Option<Bucket>, Error>
// outer unwrap: percentile value is valid
// inner unwrap: histogram is non-empty
println!("p50: {}-{}", p50.start(), p50.end());
println!("p99: {}-{}", p99.start(), p99.end());§Background
Please see: https://h2histogram.org
Structs§
- Atomic
Histogram - A histogram that uses atomic 64bit counters for each bucket.
- Bucket
- A bucket represents a quantized range of values and a count of observations that fall into that range.
- Config
- The configuration of a histogram which determines the bucketing strategy and therefore the relative error and memory utilization of a histogram.
- Histogram
- A histogram that uses plain 64bit counters for each bucket.
- Sparse
Histogram - A sparse, columnar representation of a histogram.
Enums§
- Error
- Errors returned for histogram construction and operations.