"01-introduction-exercices.ipynb" did not exist on "416f720aa3da707de17b44909f474c991165b41b"
Select Git revision
test_analyse.py
Forked from
Vuillemot Romain / INF-TC1
Source project has a limited visibility.
-
Romain Vuillemot authoredRomain Vuillemot authored
test_analyse_simple.py 797 B
import time
import random
import matplotlib.pyplot as plt
nvalues = [100, 500, 1500, 2000, 2500, 3000]
timesSorted = []
timesSort = []
for i in nvalues:
random.seed()
p = 12**2
liste = []
for x in range(i): liste.append(random.randint(0, p))
c = liste.copy()
a=time.perf_counter()
triSorted = sorted(c)
b=time.perf_counter()
timesSorted.append(b-a)
c = liste.copy()
a=time.perf_counter()
triSort = c
triSort.sort()
b=time.perf_counter()
timesSort.append(b-a)
plt.plot(nvalues, timesSorted, "g-", label="Tri 1")
plt.plot(nvalues, timesSort, "b-", label="Tri 2")
plt.xlabel("Taille du jeu de données")
plt.ylabel("Temps")
plt.legend(loc="upper left")
plt.title("Comparaison des performances des algorithmes de tri")
plt.show()