diff --git a/tp_2_miso_dict.py b/tp_2_miso_dict.py index 98d2a0c91f569e81c4b9ba67b1cf7bf2a35c8f82..bc8cd4d29535085429f7a23dcda6afb8bee50f12 100644 --- a/tp_2_miso_dict.py +++ b/tp_2_miso_dict.py @@ -11,8 +11,26 @@ def experiment_load_factor(load_factors): """ Étude du facteur de charge """ - return [],[],[] - + insertion_times = [] + resizing = [] + memory_sizes = [] + for i in load_factors: + d = {} + start_time = time.perf_counter() + resizing_count = 0 + last_memory_size = sys.getsizeof(d) + num_elements = int(i*100) + for j in range(num_elements): + d[j] = j + current_memory_size = sys.getsizeof(d) + if current_memory_size != last_memory_size : + resizing_count += 1 + last_memory_size = current_memory_size + end_time = time.perf_counter() + insertion_times.append( end_time - start_time) + resizing.append(resizing_count) + memory_sizes.append(last_memory_size) + return insertion_times, resizing, memory_sizes def experiment_longest(): """ TODO: que fait cette fonction diff --git a/tp_2_miso_mphf.py b/tp_2_miso_mphf.py index c80547823c559617c38cbaa2accf272e1e9de4cc..c48ed7ee0e69c012a825578504e98f18057a2f64 100644 --- a/tp_2_miso_mphf.py +++ b/tp_2_miso_mphf.py @@ -7,7 +7,7 @@ import random ###### PARTIE 1 ###### -def construction_mphf(set_kmer:set[str], n:int, gamma:float=2, nb_niveaux:int=3) -> list[list[int]]: +def construction_mphf(set_kmer:set[str], n:int, gamma:float=100, nb_niveaux:int=100) -> list[list[int]]: """ Construit une fonction de hachage minimale parfaite (MPHF) pour un ensemble de k-mers. @@ -85,8 +85,7 @@ def get_hash_mphf(mphf, kmer): mphf (list): Table de hachage minimale parfaite. kmer (str): K-mer à hasher. - Returns: - int: Hash du k-mer. + Returns: int: Hash du k-mer. Examples: >>> set_kmer = {str(i) for i in range(10)}