-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalysisgrapher.py
83 lines (66 loc) · 2.45 KB
/
analysisgrapher.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
76
77
78
79
80
81
82
83
# Script to analyze and graph runtimes from cuckoorings
import matplotlib.pyplot as plt
import sys
output = open(sys.argv[1])
size = 3
numloops = 20
ringtimes = [0]*numloops
cuckootimes = [0]*numloops
ringcost = [0]*numloops
cuckoocost = [0]*numloops
ringmax = [0]*numloops
cuckoomax = [0]*numloops
i = 0
for l in output:
line = l.split(",")
line = [float(j) for j in line]
i += 1
if (i % 2):
ringtimes[i/2 % numloops] += line[0]
ringcost[i/2 % numloops] += line[1]
ringmax[i/2 % numloops] += line[2]
else:
cuckootimes[(i-1)/2 % numloops] += line[0]
cuckoocost[(i-1)/2 % numloops] += line[1]
cuckoomax[(i-1)/2 % numloops] += line[2]
ringtimes = [i/size for i in ringtimes]
cuckootimes = [i/size for i in cuckootimes]
ringcost = [i/size for i in ringcost]
ringmax = [i/size for i in ringmax]
cuckoocost = [i/size for i in cuckoocost]
cuckoomax = [i/size for i in cuckoomax]
assert(len(ringtimes) == len(cuckootimes))
# runtime comparisons
plt.figure(1, figsize=(5,2))
plt.title('Time Comparison of Consistent Hashing and CuckooRings', fontsize=10)
plt.gca().set_color_cycle(['red', 'blue'])
plt.xlabel('Number of Servers removed')
plt.ylabel('Time (s)')
plt.axis([0,101000,0,6.2])
plt.plot([5000*(i) for i in range(20)], ringtimes)
plt.plot([5000*(i) for i in range(20)], cuckootimes)
plt.legend(['Standard Consistent Hashing', 'CuckooRings'], loc = 'upper left', prop={'size':6})
# cost function plotting
plt.figure(2, figsize=(5,2))
plt.gca().set_color_cycle(['red', 'blue'])
plt.title('Cost Comparison of Consistent Hashing and CuckooRings', fontsize=10)
plt.xlabel('Number of Servers removed')
plt.ylabel('Cost (average squared load)')
plt.axis([0,101000,0,5])
plt.plot([5000*(i) for i in range(20)], ringcost)
plt.plot([5000*(i) for i in range(20)], cuckoocost)
plt.legend(['Standard Consistent Hashing', 'CuckooRings'], loc = 'upper left', prop={'size':6})
# max load plotting
plt.figure(3, figsize=(5,2))
plt.gca().set_color_cycle(['red', 'blue'])
plt.title('Max Load Comparison of Consistent Hashing and CuckooRings', fontsize=10)
plt.xlabel('Number of Servers removed')
plt.ylabel('Max load')
#plt.axis([80000,2020000,0,23])
plt.axis([0,101000,0,23])
plt.scatter([5000*(i) for i in range(20)], ringmax, c='red')
plt.scatter([5000*(i) for i in range(20)], cuckoomax)
plt.legend(['Standard Consistent Hashing', 'CuckooRings'], loc = 'upper left', prop={'size':6})
for im in plt.gca().get_images():
im.set_color_cycle(['red', 'blue'])
plt.show()