proxygen
folly::TimeseriesHistogram< T, CT, C > Class Template Reference

#include <TimeseriesHistogram.h>

Classes

struct  AvgFromInterval
 
struct  AvgFromLevel
 
struct  CountFromInterval
 
struct  CountFromLevel
 

Public Types

using ValueType = T
 
using ContainerType = C
 
using Clock = CT
 
using Duration = typename Clock::duration
 
using TimePoint = typename Clock::time_point
 

Public Member Functions

 TimeseriesHistogram (ValueType bucketSize, ValueType min, ValueType max, const ContainerType &defaultContainer)
 
ValueType getBucketSize () const
 
ValueType getMin () const
 
ValueType getMax () const
 
size_t getNumLevels () const
 
size_t getNumBuckets () const
 
ValueType getBucketMin (size_t bucketIdx) const
 
const ContainerTypegetBucket (size_t bucketIdx) const
 
uint64_t count (size_t level) const
 
uint64_t count (TimePoint start, TimePoint end) const
 
ValueType sum (size_t level) const
 
ValueType sum (TimePoint start, TimePoint end) const
 
template<typename ReturnType = double>
ReturnType avg (size_t level) const
 
template<typename ReturnType = double>
ReturnType avg (TimePoint start, TimePoint end) const
 
template<typename ReturnType = double>
ReturnType rate (size_t level) const
 
template<typename ReturnType = double>
ReturnType rate (TimePoint start, TimePoint end) const
 
void update (TimePoint now)
 
void clear ()
 
void addValue (TimePoint now, const ValueType &value)
 
void addValue (TimePoint now, const ValueType &value, uint64_t times)
 
void addValues (TimePoint now, const folly::Histogram< ValueType > &values)
 
ValueType getPercentileEstimate (double pct, size_t level) const
 
ValueType getPercentileEstimate (double pct, TimePoint start, TimePoint end) const
 
size_t getPercentileBucketIdx (double pct, size_t level) const
 
size_t getPercentileBucketIdx (double pct, TimePoint start, TimePoint end) const
 
ValueType getPercentileBucketMin (double pct, size_t level) const
 
ValueType getPercentileBucketMin (double pct, TimePoint start, TimePoint end) const
 
std::string getString (size_t level) const
 
std::string getString (TimePoint start, TimePoint end) const
 
void update (Duration now)
 
void addValue (Duration now, const ValueType &value)
 
void addValue (Duration now, const ValueType &value, uint64_t times)
 
void addValues (Duration now, const folly::Histogram< ValueType > &values)
 

Private Types

typedef ContainerType Bucket
 

Private Member Functions

void maybeHandleSingleUniqueValue (const ValueType &value)
 
void computeAvgData (ValueType *total, uint64_t *nsamples, size_t level) const
 
void computeAvgData (ValueType *total, uint64_t *nsamples, TimePoint start, TimePoint end) const
 
void computeRateData (ValueType *total, Duration *elapsed, size_t level) const
 
void computeRateData (ValueType *total, Duration *elapsed, TimePoint start, TimePoint end) const
 

Private Attributes

folly::detail::HistogramBuckets< ValueType, ContainerTypebuckets_
 
bool haveNotSeenValue_
 
bool singleUniqueValue_
 
ValueType firstValue_
 

Detailed Description

template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
class folly::TimeseriesHistogram< T, CT, C >

Definition at line 54 of file TimeseriesHistogram.h.

Member Typedef Documentation

template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
typedef ContainerType folly::TimeseriesHistogram< T, CT, C >::Bucket
private

Definition at line 323 of file TimeseriesHistogram.h.

template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
using folly::TimeseriesHistogram< T, CT, C >::Clock = CT

Definition at line 65 of file TimeseriesHistogram.h.

template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
using folly::TimeseriesHistogram< T, CT, C >::ContainerType = C

Definition at line 63 of file TimeseriesHistogram.h.

template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
using folly::TimeseriesHistogram< T, CT, C >::Duration = typename Clock::duration

Definition at line 66 of file TimeseriesHistogram.h.

template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
using folly::TimeseriesHistogram< T, CT, C >::TimePoint = typename Clock::time_point

Definition at line 67 of file TimeseriesHistogram.h.

template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
using folly::TimeseriesHistogram< T, CT, C >::ValueType = T

Definition at line 61 of file TimeseriesHistogram.h.

Constructor & Destructor Documentation

template<typename T , typename CT , typename C >
folly::TimeseriesHistogram< T, CT, C >::TimeseriesHistogram ( ValueType  bucketSize,
ValueType  min,
ValueType  max,
const ContainerType defaultContainer 
)

Definition at line 28 of file TimeseriesHistogram-defs.h.

33  : buckets_(bucketSize, min, max, copyMe),
34  haveNotSeenValue_(true),
35  singleUniqueValue_(false) {}
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
LogLevel max
Definition: LogLevel.cpp:31
LogLevel min
Definition: LogLevel.cpp:30

Member Function Documentation

template<typename T , typename CT , typename C >
void folly::TimeseriesHistogram< T, CT, C >::addValue ( TimePoint  now,
const ValueType value 
)

Definition at line 38 of file TimeseriesHistogram-defs.h.

References folly::TimeseriesHistogram< T, CT, C >::buckets_, folly::detail::HistogramBuckets< T, BucketT >::getByValue(), and folly::TimeseriesHistogram< T, CT, C >::maybeHandleSingleUniqueValue().

Referenced by folly::TimeseriesHistogram< T, CT, C >::addValue(), folly::TimeseriesHistogram< T, CT, C >::rate(), and TEST().

40  {
41  buckets_.getByValue(value).addValue(now, value);
43 }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
std::chrono::steady_clock::time_point now()
void maybeHandleSingleUniqueValue(const ValueType &value)
BucketType & getByValue(ValueType value)
Definition: Histogram.h:93
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
template<typename T , typename CT , typename C >
void folly::TimeseriesHistogram< T, CT, C >::addValue ( TimePoint  now,
const ValueType value,
uint64_t  times 
)

Definition at line 46 of file TimeseriesHistogram-defs.h.

References folly::TimeseriesHistogram< T, CT, C >::buckets_, folly::detail::HistogramBuckets< T, BucketT >::getByValue(), and folly::TimeseriesHistogram< T, CT, C >::maybeHandleSingleUniqueValue().

49  {
50  buckets_.getByValue(value).addValue(now, value, times);
52 }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
std::chrono::steady_clock::time_point now()
void maybeHandleSingleUniqueValue(const ValueType &value)
BucketType & getByValue(ValueType value)
Definition: Histogram.h:93
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
Future< Unit > times(const int n, F &&thunk)
Definition: Future-inl.h:2348
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
void folly::TimeseriesHistogram< T, CT, C >::addValue ( Duration  now,
const ValueType value 
)
inline

Definition at line 312 of file TimeseriesHistogram.h.

References folly::TimeseriesHistogram< T, CT, C >::addValue().

312  {
314  }
std::chrono::steady_clock::time_point now()
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
void addValue(TimePoint now, const ValueType &value)
typename Clock::time_point TimePoint
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
void folly::TimeseriesHistogram< T, CT, C >::addValue ( Duration  now,
const ValueType value,
uint64_t  times 
)
inline

Definition at line 315 of file TimeseriesHistogram.h.

References folly::TimeseriesHistogram< T, CT, C >::addValue().

315  {
317  }
std::chrono::steady_clock::time_point now()
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
void addValue(TimePoint now, const ValueType &value)
Future< Unit > times(const int n, F &&thunk)
Definition: Future-inl.h:2348
typename Clock::time_point TimePoint
template<typename T , typename CT , typename C >
void folly::TimeseriesHistogram< T, CT, C >::addValues ( TimePoint  now,
const folly::Histogram< ValueType > &  values 
)

Definition at line 55 of file TimeseriesHistogram-defs.h.

References folly::TimeseriesHistogram< T, CT, C >::buckets_, folly::detail::Bucket< T >::count, folly::Histogram< T >::getBucketByIndex(), folly::TimeseriesHistogram< T, CT, C >::getBucketSize(), folly::Histogram< T >::getBucketSize(), folly::detail::HistogramBuckets< T, BucketT >::getByIndex(), folly::TimeseriesHistogram< T, CT, C >::getMax(), folly::Histogram< T >::getMax(), folly::TimeseriesHistogram< T, CT, C >::getMin(), folly::Histogram< T >::getMin(), folly::TimeseriesHistogram< T, CT, C >::getNumBuckets(), folly::Histogram< T >::getNumBuckets(), folly::TimeseriesHistogram< T, CT, C >::haveNotSeenValue_, folly::TimeseriesHistogram< T, CT, C >::singleUniqueValue_, and folly::detail::Bucket< T >::sum.

Referenced by folly::TimeseriesHistogram< T, CT, C >::addValues(), and folly::TimeseriesHistogram< T, CT, C >::rate().

57  {
58  CHECK_EQ(hist.getMin(), getMin());
59  CHECK_EQ(hist.getMax(), getMax());
60  CHECK_EQ(hist.getBucketSize(), getBucketSize());
61  CHECK_EQ(hist.getNumBuckets(), getNumBuckets());
62 
63  for (size_t n = 0; n < hist.getNumBuckets(); ++n) {
64  const typename folly::Histogram<ValueType>::Bucket& histBucket =
65  hist.getBucketByIndex(n);
66  Bucket& myBucket = buckets_.getByIndex(n);
67  myBucket.addValueAggregated(now, histBucket.sum, histBucket.count);
68  }
69 
70  // We don't bother with the singleUniqueValue_ tracking.
71  haveNotSeenValue_ = false;
72  singleUniqueValue_ = false;
73 }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
std::chrono::steady_clock::time_point now()
ValueType getBucketSize() const
BucketType & getByIndex(size_t idx)
Definition: Histogram.h:108
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
void folly::TimeseriesHistogram< T, CT, C >::addValues ( Duration  now,
const folly::Histogram< ValueType > &  values 
)
inline

Definition at line 318 of file TimeseriesHistogram.h.

References folly::TimeseriesHistogram< T, CT, C >::addValues().

318  {
319  addValues(TimePoint(now), values);
320  }
std::chrono::steady_clock::time_point now()
void addValues(TimePoint now, const folly::Histogram< ValueType > &values)
typename Clock::time_point TimePoint
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
template<typename ReturnType = double>
ReturnType folly::TimeseriesHistogram< T, CT, C >::avg ( size_t  level) const
inline

Definition at line 166 of file TimeseriesHistogram.h.

References folly::TimeseriesHistogram< T, CT, C >::computeAvgData(), and uint64_t.

Referenced by TEST().

166  {
167  auto total = ValueType();
168  uint64_t nsamples = 0;
169  computeAvgData(&total, &nsamples, level);
170  return folly::detail::avgHelper<ReturnType>(total, nsamples);
171  }
void computeAvgData(ValueType *total, uint64_t *nsamples, size_t level) const
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
template<typename ReturnType = double>
ReturnType folly::TimeseriesHistogram< T, CT, C >::avg ( TimePoint  start,
TimePoint  end 
) const
inline

Definition at line 175 of file TimeseriesHistogram.h.

References folly::TimeseriesHistogram< T, CT, C >::computeAvgData(), and uint64_t.

175  {
176  auto total = ValueType();
177  uint64_t nsamples = 0;
178  computeAvgData(&total, &nsamples, start, end);
179  return folly::detail::avgHelper<ReturnType>(total, nsamples);
180  }
void computeAvgData(ValueType *total, uint64_t *nsamples, size_t level) const
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62
auto start
template<typename T , typename CT , typename C >
void folly::TimeseriesHistogram< T, CT, C >::clear ( )

Definition at line 132 of file TimeseriesHistogram-defs.h.

References folly::TimeseriesHistogram< T, CT, C >::buckets_, folly::detail::HistogramBuckets< T, BucketT >::getByIndex(), folly::detail::HistogramBuckets< T, BucketT >::getNumBuckets(), and i.

Referenced by folly::TimeseriesHistogram< T, CT, C >::rate(), and TEST().

132  {
133  for (size_t i = 0; i < buckets_.getNumBuckets(); i++) {
134  buckets_.getByIndex(i).clear();
135  }
136 }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
size_t getNumBuckets() const
Definition: Histogram.h:85
BucketType & getByIndex(size_t idx)
Definition: Histogram.h:108
template<class T , class CT , class C >
void folly::TimeseriesHistogram< T, CT, C >::computeAvgData ( ValueType total,
uint64_t nsamples,
size_t  level 
) const
private

Definition at line 190 of file TimeseriesHistogram-defs.h.

References b, folly::TimeseriesHistogram< T, CT, C >::buckets_, folly::detail::HistogramBuckets< T, BucketT >::getByIndex(), and folly::detail::HistogramBuckets< T, BucketT >::getNumBuckets().

Referenced by folly::TimeseriesHistogram< T, CT, C >::avg().

193  {
194  for (size_t b = 0; b < buckets_.getNumBuckets(); ++b) {
195  const auto& levelObj = buckets_.getByIndex(b).getLevel(level);
196  *total += levelObj.sum();
197  *nsamples += levelObj.count();
198  }
199 }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
char b
size_t getNumBuckets() const
Definition: Histogram.h:85
BucketType & getByIndex(size_t idx)
Definition: Histogram.h:108
template<class T , class CT , class C >
void folly::TimeseriesHistogram< T, CT, C >::computeAvgData ( ValueType total,
uint64_t nsamples,
TimePoint  start,
TimePoint  end 
) const
private

Definition at line 202 of file TimeseriesHistogram-defs.h.

References b, folly::TimeseriesHistogram< T, CT, C >::buckets_, folly::detail::HistogramBuckets< T, BucketT >::getByIndex(), and folly::detail::HistogramBuckets< T, BucketT >::getNumBuckets().

206  {
207  for (size_t b = 0; b < buckets_.getNumBuckets(); ++b) {
208  const auto& levelObj = buckets_.getByIndex(b).getLevel(start);
209  *total += levelObj.sum(start, end);
210  *nsamples += levelObj.count(start, end);
211  }
212 }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
char b
size_t getNumBuckets() const
Definition: Histogram.h:85
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62
BucketType & getByIndex(size_t idx)
Definition: Histogram.h:108
auto start
template<typename T , typename CT , typename C >
void folly::TimeseriesHistogram< T, CT, C >::computeRateData ( ValueType total,
Duration elapsed,
size_t  level 
) const
private

Definition at line 215 of file TimeseriesHistogram-defs.h.

References b, folly::TimeseriesHistogram< T, CT, C >::buckets_, folly::detail::HistogramBuckets< T, BucketT >::getByIndex(), folly::detail::HistogramBuckets< T, BucketT >::getNumBuckets(), and max.

Referenced by folly::TimeseriesHistogram< T, CT, C >::rate().

218  {
219  for (size_t b = 0; b < buckets_.getNumBuckets(); ++b) {
220  const auto& levelObj = buckets_.getByIndex(b).getLevel(level);
221  *total += levelObj.sum();
222  *elapsed = std::max(*elapsed, levelObj.elapsed());
223  }
224 }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
char b
LogLevel max
Definition: LogLevel.cpp:31
size_t getNumBuckets() const
Definition: Histogram.h:85
BucketType & getByIndex(size_t idx)
Definition: Histogram.h:108
template<class T , class CT , class C >
void folly::TimeseriesHistogram< T, CT, C >::computeRateData ( ValueType total,
Duration elapsed,
TimePoint  start,
TimePoint  end 
) const
private

Definition at line 227 of file TimeseriesHistogram-defs.h.

References b, folly::TimeseriesHistogram< T, CT, C >::buckets_, folly::detail::HistogramBuckets< T, BucketT >::getByIndex(), folly::detail::HistogramBuckets< T, BucketT >::getNumBuckets(), and max.

231  {
232  for (size_t b = 0; b < buckets_.getNumBuckets(); ++b) {
233  const auto& level = buckets_.getByIndex(b).getLevel(start);
234  *total += level.sum(start, end);
235  *elapsed = std::max(*elapsed, level.elapsed(start, end));
236  }
237 }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
char b
LogLevel max
Definition: LogLevel.cpp:31
size_t getNumBuckets() const
Definition: Histogram.h:85
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62
BucketType & getByIndex(size_t idx)
Definition: Histogram.h:108
auto start
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
uint64_t folly::TimeseriesHistogram< T, CT, C >::count ( size_t  level) const
inline

Definition at line 129 of file TimeseriesHistogram.h.

References b, folly::TimeseriesHistogram< T, CT, C >::buckets_, folly::detail::HistogramBuckets< T, BucketT >::getByIndex(), folly::detail::HistogramBuckets< T, BucketT >::getNumBuckets(), and uint64_t.

Referenced by TEST().

129  {
130  uint64_t total = 0;
131  for (size_t b = 0; b < buckets_.getNumBuckets(); ++b) {
132  total += buckets_.getByIndex(b).count(level);
133  }
134  return total;
135  }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
char b
size_t getNumBuckets() const
Definition: Histogram.h:85
BucketType & getByIndex(size_t idx)
Definition: Histogram.h:108
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
uint64_t folly::TimeseriesHistogram< T, CT, C >::count ( TimePoint  start,
TimePoint  end 
) const
inline

Definition at line 138 of file TimeseriesHistogram.h.

References b, folly::TimeseriesHistogram< T, CT, C >::buckets_, folly::detail::HistogramBuckets< T, BucketT >::getByIndex(), folly::detail::HistogramBuckets< T, BucketT >::getNumBuckets(), and uint64_t.

138  {
139  uint64_t total = 0;
140  for (size_t b = 0; b < buckets_.getNumBuckets(); ++b) {
141  total += buckets_.getByIndex(b).count(start, end);
142  }
143  return total;
144  }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
char b
size_t getNumBuckets() const
Definition: Histogram.h:85
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62
BucketType & getByIndex(size_t idx)
Definition: Histogram.h:108
auto start
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
const ContainerType& folly::TimeseriesHistogram< T, CT, C >::getBucket ( size_t  bucketIdx) const
inline

Definition at line 124 of file TimeseriesHistogram.h.

References folly::TimeseriesHistogram< T, CT, C >::buckets_, and folly::detail::HistogramBuckets< T, BucketT >::getByIndex().

Referenced by TEST().

124  {
125  return buckets_.getByIndex(bucketIdx);
126  }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
BucketType & getByIndex(size_t idx)
Definition: Histogram.h:108
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
ValueType folly::TimeseriesHistogram< T, CT, C >::getBucketMin ( size_t  bucketIdx) const
inline

Definition at line 119 of file TimeseriesHistogram.h.

References folly::TimeseriesHistogram< T, CT, C >::buckets_, and folly::detail::HistogramBuckets< T, BucketT >::getBucketMin().

Referenced by folly::TimeseriesHistogram< T, CT, C >::getPercentileBucketMin().

119  {
120  return buckets_.getBucketMin(bucketIdx);
121  }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
ValueType getBucketMin(size_t idx) const
Definition: Histogram.h:124
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
ValueType folly::TimeseriesHistogram< T, CT, C >::getBucketSize ( ) const
inline

Definition at line 90 of file TimeseriesHistogram.h.

References folly::TimeseriesHistogram< T, CT, C >::buckets_, and folly::detail::HistogramBuckets< T, BucketT >::getBucketSize().

Referenced by folly::TimeseriesHistogram< T, CT, C >::addValues(), and TEST().

90  {
91  return buckets_.getBucketSize();
92  }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
ValueType getBucketSize() const
Definition: Histogram.h:64
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
ValueType folly::TimeseriesHistogram< T, CT, C >::getMax ( ) const
inline

Definition at line 100 of file TimeseriesHistogram.h.

References folly::TimeseriesHistogram< T, CT, C >::buckets_, and folly::detail::HistogramBuckets< T, BucketT >::getMax().

Referenced by folly::TimeseriesHistogram< T, CT, C >::addValues(), and TEST().

100  {
101  return buckets_.getMax();
102  }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
ValueType getMax() const
Definition: Histogram.h:74
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
ValueType folly::TimeseriesHistogram< T, CT, C >::getMin ( ) const
inline

Definition at line 95 of file TimeseriesHistogram.h.

References folly::TimeseriesHistogram< T, CT, C >::buckets_, and folly::detail::HistogramBuckets< T, BucketT >::getMin().

Referenced by folly::TimeseriesHistogram< T, CT, C >::addValues(), and TEST().

95  {
96  return buckets_.getMin();
97  }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
ValueType getMin() const
Definition: Histogram.h:69
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
size_t folly::TimeseriesHistogram< T, CT, C >::getNumBuckets ( ) const
inline

Definition at line 110 of file TimeseriesHistogram.h.

References folly::TimeseriesHistogram< T, CT, C >::buckets_, and folly::detail::HistogramBuckets< T, BucketT >::getNumBuckets().

Referenced by folly::TimeseriesHistogram< T, CT, C >::addValues(), and TEST().

110  {
111  return buckets_.getNumBuckets();
112  }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
size_t getNumBuckets() const
Definition: Histogram.h:85
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
size_t folly::TimeseriesHistogram< T, CT, C >::getNumLevels ( ) const
inline

Definition at line 105 of file TimeseriesHistogram.h.

References folly::TimeseriesHistogram< T, CT, C >::buckets_, and folly::detail::HistogramBuckets< T, BucketT >::getByIndex().

Referenced by TEST().

105  {
106  return buckets_.getByIndex(0).numLevels();
107  }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
BucketType & getByIndex(size_t idx)
Definition: Histogram.h:108
template<typename T , typename CT , typename C >
size_t folly::TimeseriesHistogram< T, CT, C >::getPercentileBucketIdx ( double  pct,
size_t  level 
) const

Definition at line 116 of file TimeseriesHistogram-defs.h.

References folly::TimeseriesHistogram< T, CT, C >::buckets_, and folly::detail::HistogramBuckets< T, BucketT >::getPercentileBucketIdx().

Referenced by folly::TimeseriesHistogram< T, CT, C >::getPercentileBucketMin(), and folly::TimeseriesHistogram< T, CT, C >::rate().

118  {
119  return buckets_.getPercentileBucketIdx(pct / 100.0, CountFromLevel(level));
120 }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
size_t getPercentileBucketIdx(double pct, CountFn countFromBucket, double *lowPct=nullptr, double *highPct=nullptr) const
template<typename T , typename CT , typename C >
size_t folly::TimeseriesHistogram< T, CT, C >::getPercentileBucketIdx ( double  pct,
TimePoint  start,
TimePoint  end 
) const

Definition at line 123 of file TimeseriesHistogram-defs.h.

References folly::TimeseriesHistogram< T, CT, C >::buckets_, and folly::detail::HistogramBuckets< T, BucketT >::getPercentileBucketIdx().

126  {
128  pct / 100.0, CountFromInterval(start, end));
129 }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62
auto start
size_t getPercentileBucketIdx(double pct, CountFn countFromBucket, double *lowPct=nullptr, double *highPct=nullptr) const
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
ValueType folly::TimeseriesHistogram< T, CT, C >::getPercentileBucketMin ( double  pct,
size_t  level 
) const
inline

Definition at line 280 of file TimeseriesHistogram.h.

References folly::TimeseriesHistogram< T, CT, C >::getBucketMin(), and folly::TimeseriesHistogram< T, CT, C >::getPercentileBucketIdx().

Referenced by TEST().

280  {
281  return getBucketMin(getPercentileBucketIdx(pct, level));
282  }
ValueType getBucketMin(size_t bucketIdx) const
size_t getPercentileBucketIdx(double pct, size_t level) const
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
ValueType folly::TimeseriesHistogram< T, CT, C >::getPercentileBucketMin ( double  pct,
TimePoint  start,
TimePoint  end 
) const
inline

Definition at line 284 of file TimeseriesHistogram.h.

References folly::TimeseriesHistogram< T, CT, C >::getBucketMin(), folly::TimeseriesHistogram< T, CT, C >::getPercentileBucketIdx(), folly::TimeseriesHistogram< T, CT, C >::getString(), and string.

285  {
287  }
ValueType getBucketMin(size_t bucketIdx) const
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62
auto start
size_t getPercentileBucketIdx(double pct, size_t level) const
template<typename T , typename CT , typename C >
T folly::TimeseriesHistogram< T, CT, C >::getPercentileEstimate ( double  pct,
size_t  level 
) const

Definition at line 90 of file TimeseriesHistogram-defs.h.

References folly::TimeseriesHistogram< T, CT, C >::buckets_, folly::TimeseriesHistogram< T, CT, C >::firstValue_, folly::detail::HistogramBuckets< T, BucketT >::getPercentileEstimate(), and folly::TimeseriesHistogram< T, CT, C >::singleUniqueValue_.

Referenced by folly::TimeseriesHistogram< T, CT, C >::rate(), and TEST().

91  {
92  if (singleUniqueValue_) {
93  return firstValue_;
94  }
95 
97  pct / 100.0, CountFromLevel(level), AvgFromLevel(level));
98 }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
ValueType getPercentileEstimate(double pct, CountFn countFromBucket, AvgFn avgFromBucket) const
template<typename T , typename CT , typename C >
T folly::TimeseriesHistogram< T, CT, C >::getPercentileEstimate ( double  pct,
TimePoint  start,
TimePoint  end 
) const

Definition at line 101 of file TimeseriesHistogram-defs.h.

References folly::TimeseriesHistogram< T, CT, C >::buckets_, folly::TimeseriesHistogram< T, CT, C >::firstValue_, folly::detail::HistogramBuckets< T, BucketT >::getPercentileEstimate(), and folly::TimeseriesHistogram< T, CT, C >::singleUniqueValue_.

104  {
105  if (singleUniqueValue_) {
106  return firstValue_;
107  }
108 
110  pct / 100.0,
111  CountFromInterval(start, end),
112  AvgFromInterval<T>(start, end));
113 }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
ValueType getPercentileEstimate(double pct, CountFn countFromBucket, AvgFn avgFromBucket) const
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62
auto start
template<typename T , typename CT , typename C >
std::string folly::TimeseriesHistogram< T, CT, C >::getString ( size_t  level) const

Definition at line 146 of file TimeseriesHistogram-defs.h.

References folly::TimeseriesHistogram< T, CT, C >::buckets_, folly::detail::HistogramBuckets< T, BucketT >::getBucketMin(), folly::detail::HistogramBuckets< T, BucketT >::getByIndex(), folly::detail::HistogramBuckets< T, BucketT >::getNumBuckets(), i, string, and folly::toAppend().

Referenced by folly::TimeseriesHistogram< T, CT, C >::getPercentileBucketMin(), and TEST().

146  {
147  std::string result;
148 
149  for (size_t i = 0; i < buckets_.getNumBuckets(); i++) {
150  if (i > 0) {
151  toAppend(",", &result);
152  }
153  const ContainerType& cont = buckets_.getByIndex(i);
154  toAppend(
156  ":",
157  cont.count(level),
158  ":",
159  cont.template avg<ValueType>(level),
160  &result);
161  }
162 
163  return result;
164 }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
size_t getNumBuckets() const
Definition: Histogram.h:85
ValueType getBucketMin(size_t idx) const
Definition: Histogram.h:124
BucketType & getByIndex(size_t idx)
Definition: Histogram.h:108
void toAppend(char value, Tgt *result)
Definition: Conv.h:406
const char * string
Definition: Conv.cpp:212
template<typename T , typename CT , typename C >
std::string folly::TimeseriesHistogram< T, CT, C >::getString ( TimePoint  start,
TimePoint  end 
) const

Definition at line 167 of file TimeseriesHistogram-defs.h.

References folly::TimeseriesHistogram< T, CT, C >::buckets_, folly::detail::HistogramBuckets< T, BucketT >::getBucketMin(), folly::detail::HistogramBuckets< T, BucketT >::getByIndex(), folly::detail::HistogramBuckets< T, BucketT >::getNumBuckets(), i, string, and folly::toAppend().

169  {
170  std::string result;
171 
172  for (size_t i = 0; i < buckets_.getNumBuckets(); i++) {
173  if (i > 0) {
174  toAppend(",", &result);
175  }
176  const ContainerType& cont = buckets_.getByIndex(i);
177  toAppend(
179  ":",
180  cont.count(start, end),
181  ":",
182  cont.avg(start, end),
183  &result);
184  }
185 
186  return result;
187 }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
size_t getNumBuckets() const
Definition: Histogram.h:85
ValueType getBucketMin(size_t idx) const
Definition: Histogram.h:124
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62
BucketType & getByIndex(size_t idx)
Definition: Histogram.h:108
void toAppend(char value, Tgt *result)
Definition: Conv.h:406
auto start
const char * string
Definition: Conv.cpp:212
template<typename T , typename CT , typename C >
void folly::TimeseriesHistogram< T, CT, C >::maybeHandleSingleUniqueValue ( const ValueType value)
private
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
template<typename ReturnType = double>
ReturnType folly::TimeseriesHistogram< T, CT, C >::rate ( size_t  level) const
inline

Definition at line 187 of file TimeseriesHistogram.h.

References folly::TimeseriesHistogram< T, CT, C >::computeRateData().

Referenced by TEST().

187  {
188  auto total = ValueType();
189  Duration elapsed(0);
190  computeRateData(&total, &elapsed, level);
191  return folly::detail::rateHelper<ReturnType, Duration, Duration>(
192  total, elapsed);
193  }
void computeRateData(ValueType *total, Duration *elapsed, size_t level) const
StatsClock::duration Duration
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
template<typename ReturnType = double>
ReturnType folly::TimeseriesHistogram< T, CT, C >::rate ( TimePoint  start,
TimePoint  end 
) const
inline
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
ValueType folly::TimeseriesHistogram< T, CT, C >::sum ( size_t  level) const
inline

Definition at line 147 of file TimeseriesHistogram.h.

References b, folly::TimeseriesHistogram< T, CT, C >::buckets_, folly::detail::HistogramBuckets< T, BucketT >::getByIndex(), and folly::detail::HistogramBuckets< T, BucketT >::getNumBuckets().

Referenced by TEST().

147  {
148  ValueType total = ValueType();
149  for (size_t b = 0; b < buckets_.getNumBuckets(); ++b) {
150  total += buckets_.getByIndex(b).sum(level);
151  }
152  return total;
153  }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
char b
size_t getNumBuckets() const
Definition: Histogram.h:85
BucketType & getByIndex(size_t idx)
Definition: Histogram.h:108
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
ValueType folly::TimeseriesHistogram< T, CT, C >::sum ( TimePoint  start,
TimePoint  end 
) const
inline

Definition at line 156 of file TimeseriesHistogram.h.

References b, folly::TimeseriesHistogram< T, CT, C >::buckets_, folly::detail::HistogramBuckets< T, BucketT >::getByIndex(), and folly::detail::HistogramBuckets< T, BucketT >::getNumBuckets().

156  {
157  ValueType total = ValueType();
158  for (size_t b = 0; b < buckets_.getNumBuckets(); ++b) {
159  total += buckets_.getByIndex(b).sum(start, end);
160  }
161  return total;
162  }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
char b
size_t getNumBuckets() const
Definition: Histogram.h:85
auto end(TestAdlIterable &instance)
Definition: ForeachTest.cpp:62
BucketType & getByIndex(size_t idx)
Definition: Histogram.h:108
auto start
template<typename T , typename CT , typename C >
void folly::TimeseriesHistogram< T, CT, C >::update ( TimePoint  now)

Definition at line 139 of file TimeseriesHistogram-defs.h.

References folly::TimeseriesHistogram< T, CT, C >::buckets_, folly::detail::HistogramBuckets< T, BucketT >::getByIndex(), folly::detail::HistogramBuckets< T, BucketT >::getNumBuckets(), and i.

Referenced by folly::TimeseriesHistogram< T, CT, C >::rate(), TEST(), and folly::TimeseriesHistogram< T, CT, C >::update().

139  {
140  for (size_t i = 0; i < buckets_.getNumBuckets(); i++) {
141  buckets_.getByIndex(i).update(now);
142  }
143 }
folly::detail::HistogramBuckets< ValueType, ContainerType > buckets_
std::chrono::steady_clock::time_point now()
size_t getNumBuckets() const
Definition: Histogram.h:85
BucketType & getByIndex(size_t idx)
Definition: Histogram.h:108
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
void folly::TimeseriesHistogram< T, CT, C >::update ( Duration  now)
inline

Definition at line 309 of file TimeseriesHistogram.h.

References folly::TimeseriesHistogram< T, CT, C >::update().

309  {
310  update(TimePoint(now));
311  }
std::chrono::steady_clock::time_point now()
typename Clock::time_point TimePoint

Member Data Documentation

template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
ValueType folly::TimeseriesHistogram< T, CT, C >::firstValue_
private
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
bool folly::TimeseriesHistogram< T, CT, C >::haveNotSeenValue_
private
template<class T, class CT = LegacyStatsClock<std::chrono::seconds>, class C = folly::MultiLevelTimeSeries<T, CT>>
bool folly::TimeseriesHistogram< T, CT, C >::singleUniqueValue_
private

The documentation for this class was generated from the following files: