00001
00002
00003
00004
00005 #ifndef MEDIDA_EWMA_H_
00006 #define MEDIDA_EWMA_H_
00007
00008 #include <chrono>
00009 #include <cstdint>
00010 #include <memory>
00011
00012 namespace medida {
00013 namespace stats {
00014
00015 class EWMA {
00016 public:
00017 EWMA() = delete;
00018 EWMA(double alpha, std::chrono::nanoseconds interval);
00019 EWMA(EWMA &&other);
00020 ~EWMA();
00021 static EWMA oneMinuteEWMA();
00022 static EWMA fiveMinuteEWMA();
00023 static EWMA fifteenMinuteEWMA();
00024 void update(std::int64_t n);
00025 void tick();
00026 double getRate(std::chrono::nanoseconds duration = std::chrono::seconds {1}) const;
00027 private:
00028 class Impl;
00029 std::unique_ptr<Impl> impl_;
00030 };
00031
00032 }
00033 }
00034
00035 #endif // MEDIDA_EWMA_H_