This repository has been archived by the owner on Nov 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Time.py
73 lines (65 loc) · 1.97 KB
/
Time.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import time
from Fibonacci import Fibonacci
from Tri import *
def iteratif_lineair_time():
f, times, iterations = Fibonacci(), [], []
for i in range(1, 500, 5):
start = time.time()
for j in range(0, 10000):
f.iteratif_lineair(i)
end = time.time()
e_time = end-start
times.append(e_time)
iterations.append(i)
return (times, iterations)
def recursif_time():
f, times, iterations = Fibonacci(), [], []
for i in range(1, 35):
begin = time.time()
f.recursif(i)
end = time.time()
e_time = end - begin
times.append(e_time)
iterations.append(i)
return (times, iterations)
def iteratif_super_time():
f, times, iterations = Fibonacci(), [], []
for i in range(1, 500, 5):
begin = time.time()
for j in range(0, 10000):
f.iteratif_super(i)
end = time.time()
e_time = end - begin
times.append(e_time)
iterations.append(i)
return (times, iterations)
def tri_time():
time_b = []
time_i = []
time_c = []
nb = 50
numbers = range(10, 1000, 50)
tri = Tri()
for nb in numbers:
time_e = [0, 0, 0]
for i in range(1, nb):
random.seed(i)
liste_b = random.sample(range(1, nb), (nb - 1))
liste_i = liste_b
liste_c = liste_b
begin_b = time.time()
tri.bulle(liste_b)
end_b = time.time()
time_e[0] = time_e[0] + (end_b - begin_b)
begin_i = time.time()
tri.insertion(liste_i)
end_i = time.time()
time_e[1] = time_e[1] + (end_i - begin_i)
begin_c = time.time()
tri.comptage(liste_c)
end_c = time.time()
time_e[2] = time_e[2] + (end_c - begin_c)
time_b.append(time_e[0] / nb)
time_i.append(time_e[1] / nb)
time_c.append(time_e[2] / nb)
return (time_b, time_i, time_c, numbers)