1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! 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 with `u64` counters. Use for
//! single-threaded recording and percentile queries.
//! - [`AtomicHistogram`] — atomic histogram for concurrent recording. Take a
//! snapshot with [`AtomicHistogram::load`] or [`AtomicHistogram::drain`] to
//! query percentiles.
//! - [`SparseHistogram`] — compact representation storing only non-zero
//! buckets. Useful for serialization and storage.
//! - [`CumulativeROHistogram`] — read-only histogram with cumulative counts
//! for fast quantile queries via binary search.
//!
//! # 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>
pub use AtomicHistogram;
pub use Bucket;
pub use Config;
pub use CumulativeROHistogram;
pub use Error;
pub use ;
pub use SparseHistogram;
pub use Histogram;