/*
- * Copyright 2017 Facebook, Inc.
+ * Copyright 2013-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#pragma once
-#include <string>
#include <folly/stats/Histogram.h>
#include <folly/stats/MultiLevelTimeSeries.h>
+#include <string>
namespace folly {
class C = folly::MultiLevelTimeSeries<T, CT>>
class TimeseriesHistogram {
private:
- // NOTE: T must be equivalent to _signed_ numeric type for our math.
- static_assert(std::numeric_limits<T>::is_signed, "");
+ // NOTE: T must be equivalent to _signed_ numeric type for our math.
+ static_assert(std::numeric_limits<T>::is_signed, "");
public:
// Values to be inserted into container
* @param defaultContainer a pre-initialized timeseries with the desired
* number of levels and their durations.
*/
- TimeseriesHistogram(ValueType bucketSize, ValueType min, ValueType max,
- const ContainerType& defaultContainer);
+ TimeseriesHistogram(
+ ValueType bucketSize,
+ ValueType min,
+ ValueType max,
+ const ContainerType& defaultContainer);
/* Return the bucket size of each bucket in the histogram. */
- ValueType getBucketSize() const { return buckets_.getBucketSize(); }
+ ValueType getBucketSize() const {
+ return buckets_.getBucketSize();
+ }
/* Return the min value at which bucketing begins. */
- ValueType getMin() const { return buckets_.getMin(); }
+ ValueType getMin() const {
+ return buckets_.getMin();
+ }
/* Return the max value at which bucketing ends. */
- ValueType getMax() const { return buckets_.getMax(); }
+ ValueType getMax() const {
+ return buckets_.getMax();
+ }
/* Return the number of levels of the Timeseries object in each bucket */
size_t getNumLevels() const {
}
/* Total sum of values at the given timeseries level (all buckets). */
- ValueType sum(int level) const {
+ ValueType sum(size_t level) const {
ValueType total = ValueType();
for (size_t b = 0; b < buckets_.getNumBuckets(); ++b) {
total += buckets_.getByIndex(b).sum(level);
/* Average of values at the given timeseries level (all buckets). */
template <typename ReturnType = double>
- ReturnType avg(int level) const {
+ ReturnType avg(size_t level) const {
auto total = ValueType();
uint64_t nsamples = 0;
computeAvgData(&total, &nsamples, level);
bool singleUniqueValue_;
ValueType firstValue_;
};
-} // folly
+} // namespace folly