Outils pour utilisateurs

Outils du site


nsi:premiere:tableau:recherche:comparaison

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

nsi:premiere:tableau:recherche:comparaison [2022/03/18 16:27] – créée goupillwikinsi:premiere:tableau:recherche:comparaison [2023/03/07 14:40] (Version actuelle) – goupillwiki
Ligne 9: Ligne 9:
 <code python> <code python>
 from random import randrange from random import randrange
-from time import time_ns+from time import perf_counter_ns as chrono
  
 # n'oubliez pas d'importer ou recopier vos fonctions # n'oubliez pas d'importer ou recopier vos fonctions
Ligne 22: Ligne 22:
  
 # cas séquentiel : # cas séquentiel :
-depart = time_ns()+depart = chrono()
 i = recherche_sequentielle(T, needle) i = recherche_sequentielle(T, needle)
-fin = time_ns()+fin = chrono()
 duree = fin - depart duree = fin - depart
 print(f"recherche sequentielle renvoie {i} en {duree} ns.") print(f"recherche sequentielle renvoie {i} en {duree} ns.")
  
 # cas dichotomique # cas dichotomique
-depart = time_ns()+depart = chrono()
 T.sort() T.sort()
-fin = time_ns()+fin = chrono()
 duree = fin - depart duree = fin - depart
 print(f"Le tri a nécessité {duree} ns.") print(f"Le tri a nécessité {duree} ns.")
  
-depart = time_ns()+depart = chrono()
 i = recherche_dichotomique(T, needle) i = recherche_dichotomique(T, needle)
-fin = time_ns()+fin = chrono()
 print(f"recherche dichotomique renvoie {i} en {duree} ns.") print(f"recherche dichotomique renvoie {i} en {duree} ns.")
 </code> </code>
nsi/premiere/tableau/recherche/comparaison.1647617233.txt.gz · Dernière modification : de goupillwiki