コード例 #1
0
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)
コード例 #2
0
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)
コード例 #3
0
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))
コード例 #4
0
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))
コード例 #5
0
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))
コード例 #6
0
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))