def test_fold_stdev(self): """ Tests the standard deviations of counters is properly computed. """ now = 10 metrics = [Timer("k", 10), Timer("k", 15), Timer("j", 7.9), Timer("j", 8)] result = Timer.fold(metrics, now) assert ("timers.k.stdev", Timer._stdev([10, 15], 12.5), now) == self._get_metric("timers.k.stdev", result) assert ("timers.j.stdev", Timer._stdev([7.9, 8], 7.95), now) == self._get_metric("timers.j.stdev", result)
def test_stdev(self): """ Tests that the standard deviation is properly computed. """ numbers = [0.331002, 0.591082, 0.668996, 0.422566, 0.458904, 0.868717, 0.30459, 0.513035, 0.900689, 0.655826] average = sum(numbers) / len(numbers) assert int(0.205767 * 10000) == int(Timer._stdev(numbers, average) * 10000)