Пример #1
0
 def test_roll_hll_counter(self):
     # rough sleep to get us back on track
     time.sleep(5.0 - (time.time() % 5.0))
     counter = HyperLogLogCounter(key='test_key', window=5, roll=True,
                                  cycle_time=.1,)
     counter.setup(redis_conn=self.redis_conn)
     i = 0
     while i < 5010:
         counter.increment(i % 1010)
         i += 1
     value = 1010
     actual = counter.value()
     diff = self.get_percent_diff(value, actual)
     self.assertLessEqual(diff, self.tolerance)
     self.clean_keys(counter.key)
     # rough sleep to get us back on track
     time.sleep(5.0 - (time.time() % 5.0))
     # we should be on to a new counter window by now
     i = 0
     while i < 5010:
         counter.increment(i % 3010)
         i += 1
     value = 3010
     actual = counter.value()
     diff = self.get_percent_diff(value, actual)
     self.assertLessEqual(diff, self.tolerance)
     counter.stop()
     self.clean_keys(counter.key)
Пример #2
0
 def test_roll_hll_counter(self):
     # rough sleep to get us back on track
     time.sleep(5.0 - (time.time() % 5.0))
     counter = HyperLogLogCounter(
         key='test_key',
         window=5,
         roll=True,
         cycle_time=.1,
     )
     counter.setup(redis_conn=self.redis_conn)
     i = 0
     while i < 5010:
         counter.increment(i % 1010)
         i += 1
     value = 1010
     actual = counter.value()
     diff = self.get_percent_diff(value, actual)
     self.assertLessEqual(diff, self.tolerance)
     self.clean_keys(counter.key)
     # rough sleep to get us back on track
     time.sleep(5.0 - (time.time() % 5.0))
     # we should be on to a new counter window by now
     i = 0
     while i < 5010:
         counter.increment(i % 3010)
         i += 1
     value = 3010
     actual = counter.value()
     diff = self.get_percent_diff(value, actual)
     self.assertLessEqual(diff, self.tolerance)
     counter.stop()
     self.clean_keys(counter.key)
Пример #3
0
    def test_hll_counter(self):
        counter = HyperLogLogCounter(key='test_key')
        counter.setup(redis_conn=self.redis_conn)
        for n in range(3):
            i = 0
            while i < 10010 * (n + 1):
                counter.increment(i % (5000 * (n + 1)))
                i += 1

            value = 5000 * (n + 1)
            actual = counter.value()
            diff = self.get_percent_diff(value, actual)
            self.assertLessEqual(diff, self.tolerance)
            self.clean_keys(counter.key)

        counter.stop()
Пример #4
0
    def test_hll_counter(self):
        counter = HyperLogLogCounter(key='test_key')
        counter.setup(redis_conn=self.redis_conn)
        for n in range(3):
            i = 0
            while i < 10010 * (n + 1):
                counter.increment(i % (5000 * (n + 1)))
                i += 1

            value = 5000 * (n + 1)
            actual = counter.value()
            diff = self.get_percent_diff(value, actual)
            self.assertLessEqual(diff, self.tolerance)
            self.clean_keys(counter.key)

        counter.stop()