38 template <
typename T,
typename BucketT>
61 const BucketType& defaultBucket);
159 template <
typename CountFn>
178 template <
typename CountFn>
181 CountFn countFromBucket,
182 double* lowPct =
nullptr,
183 double* highPct =
nullptr)
const;
197 template <
typename CountFn,
typename AvgFn>
200 CountFn countFromBucket,
201 AvgFn avgFromBucket)
const;
210 typename std::vector<BucketType>::const_iterator
begin()
const {
213 typename std::vector<BucketType>::iterator
begin() {
216 typename std::vector<BucketType>::const_iterator
end()
const {
219 typename std::vector<BucketType>::iterator
end() {
242 template <
typename T>
249 :
buckets_(bucketSize, min, max, Bucket()) {}
253 Bucket& bucket =
buckets_.getByValue(value);
264 Bucket& bucket =
buckets_.getByValue(value);
270 bucket.
count += nSamples;
281 Bucket& bucket =
buckets_.getByValue(value);
285 if (bucket.
count > 0) {
297 Bucket& bucket =
buckets_.getByValue(value);
299 if (bucket.
count >= nSamples) {
300 bucket.
sum -= value * nSamples;
301 bucket.
count -= nSamples;
310 for (
size_t i = 0;
i <
buckets_.getNumBuckets();
i++) {
321 throw std::invalid_argument(
"Cannot subtract input histogram.");
324 for (
size_t i = 0;
i <
buckets_.getNumBuckets();
i++) {
335 throw std::invalid_argument(
"Cannot merge from input histogram.");
338 for (
size_t i = 0;
i <
buckets_.getNumBuckets();
i++) {
348 throw std::invalid_argument(
"Cannot copy from input histogram.");
351 for (
size_t i = 0;
i <
buckets_.getNumBuckets();
i++) {
407 return buckets_.computeTotalCount(countFn);
418 double* lowPct =
nullptr,
419 double* highPct =
nullptr)
const {
423 return buckets_.getPercentileBucketIdx(pct, countFn, lowPct, highPct);
437 return buckets_.getPercentileEstimate(pct, countFn, avgFn);
449 void toTSV(std::ostream& out,
bool skipEmptyBuckets =
true)
const;
458 if (bucket.
count == 0) {
498 #if defined(_MSC_VER) && _MSC_FULL_VER >= 191125506 && \ 499 _MSC_FULL_VER <= 191125547 500 #define FOLLY_MSVC_USE_WORKAROUND_FOR_C5037 1 502 #define FOLLY_MSVC_USE_WORKAROUND_FOR_C5037 0 505 #if FOLLY_MSVC_USE_WORKAROUND_FOR_C5037 ValueType getPercentileEstimate(double pct) const
ValueType getBucketSize() const
const BucketType & getByValue(ValueType value) const
void removeRepeatedValue(ValueType value, uint64_t nSamples)
ValueType getPercentileEstimate(double pct, CountFn countFromBucket, AvgFn avgFromBucket) const
ValueType getBucketMax(size_t idx) const
void addValue(ValueType value)
size_t getPercentileBucketIdx(double pct, double *lowPct=nullptr, double *highPct=nullptr) const
void removeValue(ValueType value)
ValueType getBucketMax(size_t idx) const
const Bucket & getBucketByIndex(size_t idx) const
static constexpr _t< std::make_unsigned< S > > to_unsigned(S s)
ValueType getBucketSize() const
size_t getBucketIdx(ValueType value) const
Histogram(ValueType bucketSize, ValueType min, ValueType max)
std::vector< BucketType >::iterator end()
—— Concurrent Priority Queue Implementation ——
uint64_t computeTotalCount(CountFn countFromBucket) const
uint64_t computeTotalCount() const
ValueType operator()(const Bucket &bucket) const
void addRepeatedValue(ValueType value, uint64_t nSamples)
std::vector< BucketType >::const_iterator end() const
uint64_t operator()(const Bucket &bucket) const
constexpr auto to_unsigned(T const &t) -> typename std::make_unsigned< T >::type
BucketType & getByValue(ValueType value)
size_t getNumBuckets() const
ValueType getBucketMin(size_t idx) const
const BucketType & getByIndex(size_t idx) const
size_t getNumBuckets() const
std::vector< BucketType >::const_iterator begin() const
std::vector< BucketType > buckets_
BucketType & getByIndex(size_t idx)
ValueType getBucketMin(size_t idx) const
static constexpr S to_unsigned(S s)
void merge(const Histogram &hist)
void subtract(const Histogram &hist)
size_t getPercentileBucketIdx(double pct, CountFn countFromBucket, double *lowPct=nullptr, double *highPct=nullptr) const
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
detail::Bucket< T > Bucket
void copy(const Histogram &hist)
std::vector< BucketType >::iterator begin()
detail::HistogramBuckets< ValueType, Bucket > buckets_
HistogramBuckets(ValueType bucketSize, ValueType min, ValueType max, const BucketType &defaultBucket)