-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalyser.py
More file actions
51 lines (43 loc) · 1.79 KB
/
analyser.py
File metadata and controls
51 lines (43 loc) · 1.79 KB
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
import json
import os
import matplotlib.pyplot as plt
results_json = json.load(open('results.json', encoding='utf-8')) # type: dict
save_dir = "graphs/"
print(json.dumps(results_json, indent=4))
heuristic_names = {'RANDOM_MAX_GLOBAL_STEPS': 'RANDOM',
'RANDOM_MAX_GLOBAL_STEPS_IGNORE_COMPLETE_THREADS': 'RANDOM_IGNORE_COMPLETE',
'PROBABILISTIC_MOST_STORES_STATIC_SHUFFLE': 'PROB_STORES_SHUFFLE',
'PROBABILISTIC_MOST_STORES_STATIC': 'PROB_STORES',
'PROBABILISTIC_MOST_STORES_AND_BRANCHES_STATIC': 'PROB_STORES_BRANCHES'}
if not os.path.isdir(save_dir):
os.makedirs(save_dir)
for program_name, v in results_json.items():
scores = v # type: dict
for score_method, heuristic in scores.items():
plt.clf()
plt.figure(figsize=(12, 5))
x = [heuristic_names[x] for x in list(heuristic.keys())]
y = list(heuristic.values())
plt.bar(x, y, align='center', alpha=0.5)
plt.ylabel("Score")
plt.xticks([heuristic_names[x] for x in list(heuristic.keys())])
plt.title(str(program_name) + " " + str(score_method))
name = str(program_name) + " " + str(score_method) + ".png"
name = name.replace("/", "-").replace("<", "-").replace(">", "-")
for a, b in zip(x, y):
plt.text(a, b, str(b))
plt.savefig(save_dir + name, bbox_inches='tight')
# first_prog = results_json[list(results_json.keys())[1]]
# first_scorer = first_prog[list(first_prog.keys())[0]]
#
# pprint(first_prog)
#
# objects = list(first_scorer.keys())
#
#
# plt.bar(list(first_scorer.keys()), list(first_scorer.values()), align='center', alpha=0.5)
# plt.ylabel("Score")
# plt.xticks(objects)
# plt.title(str(list(results_json.keys())[0]) + str(list(first_prog.keys())[0]))
#
# plt.show()