-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
70 lines (62 loc) · 2.35 KB
/
main.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
import matplotlib.pyplot as plt
import json
from pathlib import Path
from subprocess import check_call
def plot_results(nb_max_threads, values, machine_name, algo_name, figsize):
initial_val = values[0]
threads = []
executions_time = []
expected_executions_time = []
executions_time_times_nb_threads = []
for nb_threads in range(1, nb_max_threads + 1):
execution_time = values[nb_threads - 1]
threads.append(str(nb_threads))
executions_time.append(execution_time)
expected_executions_time.append(initial_val / nb_threads)
executions_time_times_nb_threads.append(execution_time * nb_threads)
# plot executions_time and expected_executions_time
plt.clf()
plt.figure(figsize=figsize)
plt.bar(threads, executions_time, label="execution time", color="g")
plt.bar(
threads, expected_executions_time, label="expected execution time", color="b"
)
plt.ylabel("execution time (us)")
plt.xlabel("number of threads")
plt.legend()
plt.title(
"execution time with pool for " + algo_name + " with machine " + machine_name
)
plt.ylim([0, initial_val + 0.5])
file_name = machine_name + "_" + algo_name + "_execution_time.png"
plt.savefig(file_name)
check_call(["mv", file_name, "plots/" + machine_name])
plt.close()
# plot executions_time*nb_threads
plt.clf()
plt.figure(figsize=figsize)
plt.bar(threads, executions_time_times_nb_threads, color="g")
plt.ylabel("execution time*number of threads")
plt.xlabel("number of threads")
plt.title(
"execution time*number of threads for "
+ algo_name
+ " with machine "
+ machine_name
)
file_name = machine_name + "_" + algo_name + "_execution_time*nb_threads.png"
plt.savefig(file_name)
check_call(["mv", file_name, "plots/" + machine_name])
plt.close()
if __name__ == "__main__":
for json_file in Path().glob("*.json"):
machine_name = str(json_file).split(".")[0]
with open(json_file) as f:
data = json.load(f)
nb_max_threads = data["nb_max_threads"]
plot_results(
nb_max_threads, data["rnea"], machine_name, "rnea", data["plot_size"]
)
plot_results(
nb_max_threads, data["aba"], machine_name, "aba", data["plot_size"]
)