-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexp.py
75 lines (58 loc) · 2.01 KB
/
exp.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
74
75
import pickle
from test import start_tests
import matplotlib.pyplot as plt
from sys import version_info
assert version_info[0] == 2
def main():
hash_table_size = 1000
percents = (10, 20, 30, 40, 50, 60, 70, 75, 80, 85, 87, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100)
test_values = (hash_table_size, percents)
pickle.dump(test_values, open("test_input.pickle", "w"))
start_tests()
results = open("test_result.pickle", "r")
chained_results = pickle.load(results)
open_results = pickle.load(results)
open_collisions = open_results[0]
open_inspections = open_results[1]
# Chained hash table collisions plot
x_axis = percents
y_min = chained_results[:, 0]
y_avg = chained_results[:, 1]
y_max = chained_results[:, 2]
plt.plot(x_axis, y_min)
plt.plot(x_axis, y_avg)
plt.plot(x_axis, y_max)
plt.xlabel('Load percentage')
plt.ylabel('Collisions number')
plt.legend(['Minimum', 'Average', 'Maximum'], loc=2)
fig = plt.gcf()
fig.canvas.set_window_title('Chained hash table collisions')
plt.show()
# Open hash table collisions plot
y_min = open_collisions[:, 0]
y_avg = open_collisions[:, 1]
y_max = open_collisions[:, 2]
plt.plot(x_axis, y_min)
plt.plot(x_axis, y_avg)
plt.plot(x_axis, y_max)
plt.xlabel('Load percentage')
plt.ylabel('Collisions number')
plt.legend(['Minimum', 'Average', 'Maximum'], loc=2)
fig = plt.gcf()
fig.canvas.set_window_title('Open hash table collisions')
plt.show()
# Open hash table inspection lengths
y_min = open_inspections[:, 0]
y_avg = open_inspections[:, 1]
y_max = open_inspections[:, 2]
plt.plot(x_axis, y_min)
plt.plot(x_axis, y_avg)
plt.plot(x_axis, y_max)
plt.xlabel('Load percentage')
plt.ylabel('Inspection sequence length')
plt.legend(['Minimum', 'Average', 'Maximum'], loc=2)
fig = plt.gcf()
fig.canvas.set_window_title('Open hash table inspections length')
plt.show()
if __name__ == '__main__':
main()