# comparaisons des performances des 4 solutions de stm.py from stm import stm1, stm2, stm3, stm4 from random import randint from time import perf_counter vn = [] v1 = [] v2 = [] v3 = [] v4 = [] def valeurs(n): vn.append(n) t = [randint(-n, n) for _ in range(n)] # debut = perf_counter() # m1 = stm1(t) # v1.append(perf_counter() - debut) # debut = perf_counter() # m2 = stm2(t) # v2.append(perf_counter() - debut) # assert m2 == m1 debut = perf_counter() m3 = stm3(t) v3.append(perf_counter() - debut) # assert m3 == m2 debut = perf_counter() m4 = stm4(t) v4.append(perf_counter() - debut) assert m4 == m3 n = 100 while n < 1_000_000: print(n) valeurs(n) n *= 2 import matplotlib.pyplot as plt plt.xlabel("taille du tableau") plt.ylabel("temps en secondes") # plt.plot(vn, v1) # plt.plot(vn, v2) plt.plot(vn, v3) plt.plot(vn, v4) plt.show()