Source code for pywick.meters.timemeter

import time
from . import meter

[docs]class TimeMeter(meter.Meter): """ This meter is designed to measure the time between events and can be used to measure, for instance, the average processing time per batch of data. It is different from most other meters in terms of the methods it provides: Mmethods: * `reset()` resets the timer, setting the timer and unit counter to zero. * `value()` returns the time passed since the last `reset()`; divided by the counter value when `unit=true`. """ def __init__(self, unit): super(TimeMeter, self).__init__() self.unit = unit self.reset()
[docs] def reset(self): self.n = 0 self.time = time.time()
[docs] def value(self): return time.time() - self.time