# Path: tapes/local/average.py
# class EWMA(object):
#     @classmethod
#     def one(cls):
#         return EWMA(_M1_ALPHA, _INTERVAL)
# 
#     @classmethod
#     def five(cls):
#         return EWMA(_M5_ALPHA, _INTERVAL)
# 
#     @classmethod
#     def fifteen(cls):
#         return EWMA(_M15_ALPHA, _INTERVAL)
# 
#     def __init__(self, alpha, interval):
#         self.alpha = alpha
#         self.interval = interval
#         self.rate = 0.0
#         self.uncounted = 0
# 
#     def get_rate(self):
#         return self.rate
# 
#     def update(self, n):
#         self.uncounted += n
# 
#     def _tick_uninitialized(self):
#         count = self.uncounted
#         self.uncounted = 0
#         instant_rate = count / self.interval
#         self.rate = instant_rate
#         self.tick = self._tick_initialized
# 
#     def _tick_initialized(self):
#         count = self.uncounted
#         self.uncounted = 0
#         instant_rate = count / self.interval
#         self.rate += (self.alpha * (instant_rate - self.rate))
# 
#     tick = _tick_uninitialized
# 
# Path: tapes/local/stats.py
# class Stat(object):
# 
#     @abc.abstractmethod
#     def get_values(self):
#         raise NotImplementedError()


from time import time
from .average import EWMA
from .stats import Stat
from __future__ import division



_INTERVAL = 5.0


class Meter(Stat):
    def __init__(self):
        self.last_tick = time()
        self.count = 0
        self.m1 = EWMA.one()

# Path: tapes/local/average.py
# class EWMA(object):
#     @classmethod
#     def one(cls):
#         return EWMA(_M1_ALPHA, _INTERVAL)
# 
#     @classmethod
#     def five(cls):
#         return EWMA(_M5_ALPHA, _INTERVAL)
# 
#     @classmethod
#     def fifteen(cls):
#         return EWMA(_M15_ALPHA, _INTERVAL)
# 
#     def __init__(self, alpha, interval):
#         self.alpha = alpha
#         self.interval = interval
#         self.rate = 0.0
#         self.uncounted = 0
# 
#     def get_rate(self):
#         return self.rate
# 
#     def update(self, n):
#         self.uncounted += n
# 
#     def _tick_uninitialized(self):
#         count = self.uncounted
#         self.uncounted = 0
#         instant_rate = count / self.interval
#         self.rate = instant_rate
#         self.tick = self._tick_initialized
# 
#     def _tick_initialized(self):
#         count = self.uncounted
#         self.uncounted = 0
#         instant_rate = count / self.interval
#         self.rate += (self.alpha * (instant_rate - self.rate))
# 
#     tick = _tick_uninitialized
# 
# Path: tapes/local/stats.py
# class Stat(object):
# 
#     @abc.abstractmethod
#     def get_values(self):
#         raise NotImplementedError()


# Path: tapes/local/meter.py
from time import time
from .average import EWMA
from .stats import Stat

from __future__ import division



_INTERVAL = 5.0


class Meter(Stat):
    def __init__(self):
        self.last_tick = time()
        self.count = 0
        self.m1 = EWMA.one()

        self.m5 = EWMA.five()