Skip to main content

Crate histogram

Crate histogram 

Source
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

§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§

AtomicHistogram
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.
SparseHistogram
A sparse, columnar representation of a histogram.

Enums§

Error
Errors returned for histogram construction and operations.