def test_bset(num_entries): # start_size = h.heap().size start = time.time() bset = BloomSet(xrange(num_entries)) created_time = time.time() # created_size = h.heap().size start_positives_time = time.time() for i in xrange(num_entries): assert bset.contains(i) checked_positives_time = time.time() for i in xrange(num_entries, num_entries * 2): bset.contains(i) checked_negatives_time = time.time() t_create = created_time - start t_pos = checked_positives_time - start_positives_time t_neg = checked_negatives_time - checked_positives_time # k_size = int((created_size - start_size) / 1000.0) print ''' num_entries: {0} create time: {1}s check positives time: {2}s check negatives time: {3}s '''.format(num_entries, t_create, t_pos, t_neg)
class TestAddingElement(TestCase): def setUp(self): self.bset = BloomSet([]) def test_adding_element(self): self.bset.add_element(120) self.assertTrue(self.bset.set1, self.bset.set2)
class TestEmptyBloomSet(TestCase): def setUp(self): self.bset = BloomSet([]) def test_empty_bloom_set(self): for element in xrange(100): self.assertFalse(self.bset.contains(element))
class TestMembership(TestCase): def setUp(self): self.elements = range(100) self.bset = BloomSet(self.elements) def test_members(self): for element in self.elements: self.assertTrue(self.bset.contains(element))
def setUp(self): self.bset = BloomSet([])
def setUp(self): self.elements = range(100) self.bset = BloomSet(self.elements)
def setUp(self): self.bset = BloomSet(xrange(20))