-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot2.py
More file actions
43 lines (32 loc) · 2.04 KB
/
plot2.py
File metadata and controls
43 lines (32 loc) · 2.04 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
import matplotlib.pyplot as plt
import numpy as np
def percentage(base, cost):
return [a/b for a, b in zip(cost, base)]
fig = plt.figure()
ax = fig.add_subplot()
size_list = ['1024', '2048', '4096']
# facebook, cluster C, shuffled
chord = [336.47652980339006, 758.1627453080127, 2508.182113227886]
binary_search_in_buckets_local_routing = [163.99257221580285, 451.56303819908845, 1397.0939314484187]
binary_search_in_buckets_shortest_path_routing = [114.71094044492628, 275.2736533751831, 884.9991559515095]
binary_search_unrestricted_one_side = [217.98885095620562, 465.99588318835225, 1652.3123649104919]
binary_search_unrestricted_both_sides = [111.46780229594232, 230.4765983337206, 768.0058765416027]
total_width, n_algos = 0.8, 5
width = total_width / n_algos
x_chord = list(range(len(size_list)))
x_BS_restricted_LR = [pos + width for pos in x_chord]
x_BS_restricted_SPR = [pos + 2*width for pos in x_chord]
x_BS_unrestricted_OS =[pos + 3*width for pos in x_chord]
x_BS_unrestricted_BS = [pos + 4*width for pos in x_chord]
ax.bar(x_chord, percentage(chord, chord), width=width, label='Chord', color='#4C6643')
ax.bar(x_BS_restricted_LR, percentage(chord, binary_search_in_buckets_local_routing), width=width, label='BS in buckets with local routing', color='#AFCFA6')
ax.bar(x_BS_restricted_SPR, percentage(chord, binary_search_in_buckets_shortest_path_routing), width=width, label='BS in buckets with shortest path routing', color='#F5D44B')
ax.bar(x_BS_unrestricted_OS, percentage(chord, binary_search_unrestricted_one_side), width=width, label='BS from one side', color='#D47828')
ax.bar(x_BS_unrestricted_BS, percentage(chord, binary_search_unrestricted_both_sides), width=width, label='BS from both sides', color='#B73508')
ax.set_xticks([pos+total_width/2-width/2 for pos in x_chord], size_list)
ax.set_xlabel('network size')
ax.set_ylabel('Cost ratio to Chord')
ax.set_title('Demand-aware peer selection algorithms\n(based on Facebook traffic)')
plt.legend(fontsize=6)
plt.savefig('/Users/qingyun/Desktop/master thesis drawing/Facebook_C.pdf')
plt.show()