Include <folly/portability/SysTime.h> rather than <sys/time.h>
[folly.git] / folly / stats / MultiLevelTimeSeries.h
index 7a81046e7cd55bb1c4fa6477968cd4379cb1f6a6..f38b4e9f53503a44c443427bd21fd870d90476cd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2016 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -14,8 +14,7 @@
  * limitations under the License.
  */
 
-#ifndef FOLLY_STATS_MULTILEVELTIMESERIES_H_
-#define FOLLY_STATS_MULTILEVELTIMESERIES_H_
+#pragma once
 
 #include <chrono>
 #include <string>
@@ -73,7 +72,10 @@ class MultiLevelTimeSeries {
   /*
    * Return the number of buckets used to track time series at each level.
    */
-  size_t numBuckets() const { return numBuckets_; }
+  size_t numBuckets() const {
+    // The constructor ensures that levels_ has at least one item
+    return levels_[0].numBuckets();
+  }
 
   /*
    * Return the number of levels tracked by MultiLevelTimeSeries.
@@ -156,7 +158,7 @@ class MultiLevelTimeSeries {
    * not been called recently.
    */
   template <typename ReturnType=double, typename Interval=TimeType>
-  ValueType rate(int level) const {
+  ReturnType rate(int level) const {
     return getLevel(level).template rate<ReturnType, Interval>();
   }
 
@@ -297,7 +299,6 @@ class MultiLevelTimeSeries {
   void flush();
 
  private:
-  size_t numBuckets_;
   std::vector<Level> levels_;
 
   // Updates within the same time interval are cached
@@ -309,5 +310,3 @@ class MultiLevelTimeSeries {
 };
 
 } // folly
-
-#endif // FOLLY_STATS_MULTILEVELTIMESERIES_H_