38 int32_t unit_magnitude)
noexcept
53 int32_t unit_magnitude)
noexcept
70: lowest_trackable_value{lowest_trackable_value}
71, highest_trackable_value{highest_trackable_value}
72, significant_figures{significant_figures}
73, unit_magnitude(
floor(
log(lowest_trackable_value) /
log(2)))
75, sub_bucket_count(
pow(2, sub_bucket_half_count_magnitude + 1))
76, sub_bucket_half_count{sub_bucket_count / 2}
77, sub_bucket_mask{
int64_t{sub_bucket_count - 1} << unit_magnitude}
80, counts_len{(bucket_count + 1) * (sub_bucket_count / 2)}
82 if (lowest_trackable_value < 1) {
83 throw invalid_argument{
"min value must be greater than zero"};
85 if (significant_figures < 1 || significant_figures > 5) {
86 throw invalid_argument{
"significant figures must be between 1 and 5"};
88 if (lowest_trackable_value * 2 > highest_trackable_value) {
89 throw invalid_argument{
"highest trackable value too small"};
91 if (unit_magnitude + sub_bucket_half_count_magnitude > 61) {
92 throw invalid_argument{
"invalid magnitude"};
97: lowest_trackable_value_{config.lowest_trackable_value}
98, highest_trackable_value_{config.highest_trackable_value}
99, significant_figures_{config.significant_figures}
100, unit_magnitude_{config.unit_magnitude}
101, sub_bucket_half_count_magnitude_{config.sub_bucket_half_count_magnitude}
102, sub_bucket_count_{config.sub_bucket_count}
103, sub_bucket_half_count_{config.sub_bucket_half_count}
104, sub_bucket_mask_{config.sub_bucket_mask}
105, bucket_count_{config.bucket_count}
106, normalizing_index_offset_{0}
107, min_value_{numeric_limits<int64_t>::
max()}
111 counts_.resize(
config.counts_len);
115 int significant_figures)
125 return non_zero_min();
130 if (max_value_ == 0) {
138 return lowest_equivalent_value(
a) == lowest_equivalent_value(
b);
150 return next_non_equivalent_value(value) - 1;
155 return counts_get_normalised(counts_index_for(value));
160 return counts_get_normalised(index);
186 return lowest_equivalent_value(value) + size_of_equivalent_value_range(value);
191 return lowest_equivalent_value(value) + (size_of_equivalent_value_range(value) >> 1);
196 return counts_[normalize_index(index)];
201 min_value_ = numeric_limits<int64_t>::max();
204 fill(counts_.begin(), counts_.end(), 0);
209 return record_values(value, 1);
217 const int32_t counts_index{counts_index_for(value)};
218 if (counts_index < 0 || counts_len() <= counts_index) {
221 counts_inc_normalised(counts_index, count);
222 update_min_max(value);
228 if (normalizing_index_offset_ == 0) {
247 return pow2ceiling - unit_magnitude_ - (sub_bucket_half_count_magnitude_ + 1);
271 if (min_value_ == numeric_limits<int64_t>::max()) {
277void Histogram::counts_inc_normalised(
int32_t index,
int64_t value)
noexcept
281 total_count_ += value;
284void Histogram::update_min_max(
int64_t value)
noexcept
287 min_value_ = std::min(min_value_, value);
289 max_value_ = std::max(max_value_, value);