예제 #1
0
 def test_a_values(test_items1, test_items2, symmetric_difference, table_size=DEFAULT_TABLE_SIZE, a_value=0):
     # Test Random IBLT with pre generated hash decider
     test_set_size = len(test_items1)
     size = int(test_set_size * table_size)
     key = randint(1, 1000)
     hash_decider = Distribution.create_randomly_generated_sequence(size=1000, minimum=3,
                                                                    maximum=12, a_value=a_value,
                                                                    seed_value=key)
     start_time = time()
     bloom1, x, y = RIBLT.generate_table(test_items1, seed_key=key, table_size=size, max_hashes=12,
                                         hash_decider=hash_decider)
     end_time = time()
     table_creation_time = end_time - start_time
     start_time = time()
     bloom2, a, b = RIBLT.generate_table(test_items2, seed_key=key, table_size=size, max_hashes=12,
                                         hash_decider=hash_decider)
     end_time = time()
     table_creation_time = (end_time - start_time + table_creation_time) / 2
     start_time = time()
     result = RIBLT.compare_tables(bloom1, bloom2, key, max_hashes=12, hash_decider=hash_decider)
     end_time = time()
     comparison_time = end_time - start_time
     print(result[2])
     average_table_size = (asizeof.asizeof(bloom1) + asizeof.asizeof(bloom2)) / 2
     name = "RALOHA IBLT| a=%s" % a_value
     BloomTest.write_to_file(name, test_set_size, table_size, symmetric_difference,
                             average_table_size, table_creation_time, comparison_time, result[2])
예제 #2
0
    def test(test_items1, test_items2, symmetric_difference, table_size=DEFAULT_TABLE_SIZE):

        if len(test_items1) != len(test_items2):
            return

        test_set_size = len(test_items1)
        size = int(test_set_size * table_size)
        bloom_table = IBloomLT(m=size)

        # Test standard IBLT
        start_time = time()
        bloom1 = bloom_table.generate_table(test_items1)
        end_time = time()
        table_creation_time = end_time - start_time
        start_time = time()
        bloom2 = bloom_table.generate_table(test_items2)
        end_time = time()
        table_creation_time = (end_time - start_time + table_creation_time) / 2
        start_time = time()
        result = bloom_table.compare_tables(bloom1, bloom2)
        end_time = time()
        comparison_time = end_time - start_time
        print(result[2])
        average_table_size = (asizeof.asizeof(bloom1) + asizeof.asizeof(bloom2)) / 2

        BloomTest.write_to_file("Normal IBLT", test_set_size, table_size, symmetric_difference,
                                average_table_size, table_creation_time, comparison_time, result[2])
        # Test Random IBLT
        key = randint(1, 1000)
        start_time = time()
        bloom1, x, y = RIBLT.generate_table(test_items1, seed_key=key, table_size=size)
        end_time = time()
        table_creation_time = end_time - start_time
        start_time = time()
        bloom2, a, b = RIBLT.generate_table(test_items2, seed_key=key, table_size=size)
        end_time = time()
        table_creation_time = (end_time - start_time + table_creation_time) / 2
        start_time = time()
        result = RIBLT.compare_tables(bloom1, bloom2, key)
        end_time = time()
        comparison_time = end_time - start_time
        print(result[2])
        average_table_size = (asizeof.asizeof(bloom1) + asizeof.asizeof(bloom2)) / 2
        BloomTest.write_to_file("Random IBLT", test_set_size, table_size, symmetric_difference,
                                average_table_size, table_creation_time, comparison_time, result[2])

        # Test Random IBLT with pre generated hash decider
        key = randint(1, 1000)
        hash_decider = Distribution.create_randomly_generated_sequence(size=1000, minimum=3,
                                                                       maximum=12, a_value=0,
                                                                       seed_value=key)
        start_time = time()
        bloom1, x, y = RIBLT.generate_table(test_items1, seed_key=key, table_size=size, max_hashes=12, hash_decider=hash_decider)
        end_time = time()
        table_creation_time = end_time - start_time
        start_time = time()
        bloom2, a, b = RIBLT.generate_table(test_items2, seed_key=key, table_size=size, max_hashes=12, hash_decider=hash_decider)
        end_time = time()
        table_creation_time = (end_time - start_time + table_creation_time) / 2
        start_time = time()
        result = RIBLT.compare_tables(bloom1, bloom2, key, max_hashes=12, hash_decider=hash_decider)
        end_time = time()
        comparison_time = end_time - start_time
        print(result[2])
        average_table_size = (asizeof.asizeof(bloom1) + asizeof.asizeof(bloom2)) / 2
        BloomTest.write_to_file("RALOHA IBLT", test_set_size, table_size, symmetric_difference,
                                average_table_size, table_creation_time, comparison_time, result[2])