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
//! A fixed-size histogram for fast percentile estimation over `u64` values.
//!
//! `base2histogram` uses base-2 logarithmic bucketing to provide:
//!
//! - `O(1)` recording,
//! - bounded memory usage,
//! - percentile queries without sorting samples,
//! - optional multi-slot aggregation for sliding windows.
//!
//! The default histogram covers the full `u64` range with a fixed number of
//! buckets. Small values are represented more precisely, while larger values
//! trade precision for compactness.
//!
//! # Examples
//!
//! Basic percentile tracking:
//!
//! ```
//! use base2histogram::Histogram;
//!
//! let mut hist = Histogram::<()>::new();
//! hist.record(5);
//! hist.record(8);
//! hist.record(13);
//! hist.record_n(21, 2);
//!
//! assert_eq!(hist.total(), 5);
//! assert!(hist.percentile(0.5) <= hist.percentile(0.99));
//! ```
//!
//! Sliding-window style aggregation with slots:
//!
//! ```
//! use base2histogram::Histogram;
//!
//! let mut hist = Histogram::<&'static str>::with_slots(2);
//! hist.record_n(10, 2);
//! hist.advance("warm");
//! hist.record_n(100, 3);
//!
//! assert_eq!(hist.total(), 5);
//!
//! hist.advance("steady");
//! assert_eq!(hist.total(), 3);
//! ```
pub use DefaultLogScaleConfig;
pub use Histogram;
pub use LOG_SCALE;
pub use LogScale;
pub use LogScale3;
pub use LogScaleConfig;
pub use PercentileStats;