/*
- * Copyright 2016 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.
/*
* Return the number of levels tracked by MultiLevelTimeSeries.
*/
- size_t numLevels() const { return levels_.size(); }
+ size_t numLevels() const {
+ return levels_.size();
+ }
/*
* Get the BucketedTimeSeries backing the specified level.
* data. Otherwise you may be reading stale data if update() or flush() has
* not been called recently.
*/
- const Level& getLevel(int level) const {
- CHECK(level >= 0);
+ const Level& getLevel(size_t level) const {
CHECK_LT(level, levels_.size());
return levels_[level];
}
* data. Otherwise you may be reading stale data if update() or flush() has
* not been called recently.
*/
- ValueType sum(int level) const {
+ ValueType sum(size_t level) const {
return getLevel(level).sum();
}
* data. Otherwise you may be reading stale data if update() or flush() has
* not been called recently.
*/
- template <typename ReturnType=double>
- ReturnType avg(int level) const {
+ template <typename ReturnType = double>
+ ReturnType avg(size_t level) const {
return getLevel(level).template avg<ReturnType>();
}
* not been called recently.
*/
template <typename ReturnType = double, typename Interval = Duration>
- ReturnType rate(int level) const {
+ ReturnType rate(size_t level) const {
return getLevel(level).template rate<ReturnType, Interval>();
}
* data. Otherwise you may be reading stale data if update() or flush() has
* not been called recently.
*/
- int64_t count(int level) const {
+ uint64_t count(size_t level) const {
return getLevel(level).count();
}
* not been called recently.
*/
template <typename ReturnType = double, typename Interval = Duration>
- ReturnType countRate(int level) const {
+ ReturnType countRate(size_t level) const {
return getLevel(level).template countRate<ReturnType, Interval>();
}
/*
* Return the sum of all the data points currently tracked at this level.
*
- * This method is identical to sum(int level) above but takes in the
+ * This method is identical to sum(size_t level) above but takes in the
* duration that the user is interested in querying as the parameter.
*
* Note: you should generally call update() or flush() before accessing the
* Return the average (sum / count) of all the data points currently tracked
* at this level.
*
- * This method is identical to avg(int level) above but takes in the
+ * This method is identical to avg(size_t level) above but takes in the
* duration that the user is interested in querying as the parameter.
*
* Note: you should generally call update() or flush() before accessing the
* Return the rate (sum divided by elaspsed time) of the all data points
* currently tracked at this level.
*
- * This method is identical to rate(int level) above but takes in the
+ * This method is identical to rate(size_t level) above but takes in the
* duration that the user is interested in querying as the parameter.
*
* Note: you should generally call update() or flush() before accessing the
/*
* Return the number of data points currently tracked at this level.
*
- * This method is identical to count(int level) above but takes in the
+ * This method is identical to count(size_t level) above but takes in the
* duration that the user is interested in querying as the parameter.
*
* Note: you should generally call update() or flush() before accessing the
* data. Otherwise you may be reading stale data if update() or flush() has
* not been called recently.
*/
- int64_t count(Duration duration) const {
+ uint64_t count(Duration duration) const {
return getLevelByDuration(duration).count();
}
/*
* Return the count divided by the elapsed time tracked at this level.
*
- * This method is identical to countRate(int level) above but takes in the
+ * This method is identical to countRate(size_t level) above but takes in the
* duration that the user is interested in querying as the parameter.
*
* Note: you should generally call update() or flush() before accessing the
* data. Otherwise you may be reading stale data if update() or flush() has
* not been called recently.
*/
- int64_t count(TimePoint start, TimePoint end) const {
+ uint64_t count(TimePoint start, TimePoint end) const {
return getLevel(start).count(start, end);
}
/*
* Adds the value 'val' at time 'now' to all levels.
*/
- void addValue(TimePoint now, const ValueType& val, int64_t times);
+ void addValue(TimePoint now, const ValueType& val, uint64_t times);
/*
* Adds the value 'total' at time 'now' to all levels as the sum of
* 'nsamples' samples.
*/
void
- addValueAggregated(TimePoint now, const ValueType& total, int64_t nsamples);
+ addValueAggregated(TimePoint now, const ValueType& total, uint64_t nsamples);
/*
* Update all the levels to the specified time, doing all the necessary
void addValue(Duration now, const ValueType& value) {
addValue(TimePoint(now), value);
}
- void addValue(Duration now, const ValueType& value, int64_t times) {
+ void addValue(Duration now, const ValueType& value, uint64_t times) {
addValue(TimePoint(now), value, times);
}
void
- addValueAggregated(Duration now, const ValueType& total, int64_t nsamples) {
+ addValueAggregated(Duration now, const ValueType& total, uint64_t nsamples) {
addValueAggregated(TimePoint(now), total, nsamples);
}
// or flush() is called.
TimePoint cachedTime_;
ValueType cachedSum_;
- int cachedCount_;
+ uint64_t cachedCount_;
};
-} // folly
+} // namespace folly