Example #1
0
 def test_clear(self):
     histogram = HistogramExponentiallyDecaying()
     histogram.clear()
     histogram.update(5)
     histogram.update(15)
     self.assertEqual(5, histogram.min)
     self.assertEqual(15, histogram.max)
Example #2
0
 def test_clear(self):
     histogram = HistogramExponentiallyDecaying()
     histogram.clear()
     histogram.update(5)
     histogram.update(15)
     self.assertEqual(5, histogram.min)
     self.assertEqual(15, histogram.max)
Example #3
0
    def test_exponential_sample_mean_threaded(self):
        histogram = HistogramExponentiallyDecaying()

        def update():
            for i in range(100):
                histogram.update(5)
                histogram.update(10)

        for thread in [Thread(target=update) for i in range(10)]:
            thread.start()
            thread.join()
        self.assertEqual(7.5, histogram.mean)
Example #4
0
    def test_exponential_sample_snapshot_threaded(self):
        histogram = HistogramExponentiallyDecaying()

        def update():
            for i in range(100):
                histogram.update(i)

        for thread in [Thread(target=update) for i in range(10)]:
            thread.start()
            thread.join()
        snapshot = histogram.snapshot
        self.assertEqual(49.5, snapshot.median)
Example #5
0
 def test_exponential_sample_2000(self):
     histogram = HistogramExponentiallyDecaying()
     for i in range(2000):
         histogram.update(i)
     self.assertEqual(1999, histogram.max)
Example #6
0
 def test_exponential_sample_mean(self):
     histogram = HistogramExponentiallyDecaying()
     histogram.update(5)
     histogram.update(10)
     self.assertEqual(7.5, histogram.mean)
Example #7
0
 def test_exponential_sample_snapshot(self):
     histogram = HistogramExponentiallyDecaying()
     for i in range(100):
         histogram.update(i)
     snapshot = histogram.snapshot
     self.assertEqual(49.5, snapshot.median)
Example #8
0
 def test_exponential_sample_2000(self):
     histogram = HistogramExponentiallyDecaying()
     for i in range(2000):
         histogram.update(i)
     self.assertEqual(1999, histogram.max)
Example #9
0
 def test_exponential_sample_mean(self):
     histogram = HistogramExponentiallyDecaying()
     histogram.update(5)
     histogram.update(10)
     self.assertEqual(7.5, histogram.mean)
Example #10
0
 def test_exponential_sample_snapshot(self):
     histogram = HistogramExponentiallyDecaying()
     for i in range(100):
         histogram.update(i)
     snapshot = histogram.snapshot
     self.assertEqual(49.5, snapshot.median)