-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse_results.py
134 lines (128 loc) · 6.83 KB
/
parse_results.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
def print_pretty(network_dict, test_case_list, injection_rate_list):
print('##avg_latency')
for test_case in test_case_list:
print(test_case, end = ", ")
if(test_case == 'test_9'):
for network, data_list in network_dict.items(): # hom_0, ... , hetero_2 order
print(network, end = ", ")
print()
for injection_rate_slow in injection_rate_list:
print(injection_rate_slow, end = ", ")
for network, data_list in network_dict.items(): # hom_0, ... , hetero_2 order
for data in data_list:
if(data['test_case'] == test_case and data['injection_rate_slow'] == injection_rate_slow):
assert(data['injection_rate'] == '100')
print(data['avg_latency'], end = ", ")
print()
else:
for network, data_list in network_dict.items(): # hom_0, ... , hetero_2 order
print(network, end = ", ")
print()
for injection_rate in injection_rate_list:
print(injection_rate, end = ", ")
for network, data_list in network_dict.items(): # hom_0, ... , hetero_2 order
for data in data_list:
if(data['test_case'] == test_case and data['injection_rate'] == injection_rate):
print(data['avg_latency'], end = ", ")
print()
print()
print('##worst_latency')
for test_case in test_case_list:
print(test_case, end = ", ")
if(test_case == 'test_9'):
for network, data_list in network_dict.items(): # hom_0, ... , hetero_2 order
print(network, end = ", ")
print()
for injection_rate_slow in injection_rate_list:
print(injection_rate_slow, end = ", ")
for network, data_list in network_dict.items(): # hom_0, ... , hetero_2 order
for data in data_list:
if(data['test_case'] == test_case and data['injection_rate_slow'] == injection_rate_slow):
assert(data['injection_rate'] == '100')
print(data['worst_latency'], end = ", ")
print()
else:
for network, data_list in network_dict.items(): # hom_0, ... , hetero_2 order
print(network, end = ", ")
print()
for injection_rate in injection_rate_list:
print(injection_rate, end = ", ")
for network, data_list in network_dict.items(): # hom_0, ... , hetero_2 order
for data in data_list:
if(data['test_case'] == test_case and data['injection_rate'] == injection_rate):
print(data['worst_latency'], end = ", ")
print()
print()
print('##throughput')
for test_case in test_case_list:
print(test_case, end = ", ")
if(test_case == 'test_9'):
for network, data_list in network_dict.items(): # hom_0, ... , hetero_2 order
print(network, end = ", ")
print()
for injection_rate_slow in injection_rate_list:
print(injection_rate_slow, end = ", ")
for network, data_list in network_dict.items(): # hom_0, ... , hetero_2 order
for data in data_list:
if(data['test_case'] == test_case and data['injection_rate_slow'] == injection_rate_slow):
assert(data['injection_rate'] == '100')
print(data['throughput'], end = ", ")
print()
else:
for network, data_list in network_dict.items(): # hom_0, ... , hetero_2 order
print(network, end = ", ")
print()
for injection_rate in injection_rate_list:
print(injection_rate, end = ", ")
for network, data_list in network_dict.items(): # hom_0, ... , hetero_2 order
for data in data_list:
if(data['test_case'] == test_case and data['injection_rate'] == injection_rate):
print(data['throughput'], end = ", ")
print()
if __name__ == '__main__':
# hom_0_list = []
# hom_1_list = []
# hetero_0_list = []
# hetero_1_list = []
# hetero_2_list = []
# network_dict = {'hom_0': [], 'hom_1': [], 'hom_3': [], 'hetero_1': [], 'hetero_1_1': []}
network_dict = {'s0': [], 's1': [], 's2': [], 'as0': []}
test_case_list = ['test_0','test_3','test_5','test_7','test_9']
# test_case_list = ['test_9']
injection_rate_list = ['1','3','5','7','10','20','30','50','100']
data = {'network':None, 'test_case':None, 'injection_rate':None, 'injection_rate_slow':None, \
'avg_latency':None, 'worst_latency':None, 'throughput':None}
with open('results.txt', 'r') as in_file:
for line in in_file:
if(line.startswith('network: ')):
network = line.split('network: ')[1].strip()
elif(line.startswith('test case: ')):
test_case = line.split('test case: ')[1].strip()
elif(line.startswith('injection_rate: ')):
injection_rate = line.split('injection_rate: ')[1].strip()
elif(line.startswith('injection_rate_slow: ')):
injection_rate_slow = line.split('injection_rate_slow: ')[1].strip()
elif(line.startswith('avg latency: ')):
avg_latency = line.split('avg latency: ')[1].strip()
elif(line.startswith('worst_latency: ')):
worst_latency = line.split('worst_latency: ')[1].strip()
elif(line.startswith('throughput: ')):
throughput = line.split('throughput: ')[1].strip()
# elif(line.startswith('202')):
# assert(line.startswith('2023') or line.startswith('2022-12-31'))
elif(line.startswith('--')): # finish line
data['network'] = network
data['test_case'] = test_case
data['injection_rate'] = injection_rate
data['injection_rate_slow'] = injection_rate_slow
data['avg_latency'] = avg_latency
data['worst_latency'] = worst_latency
data['throughput'] = throughput
# print(data)
network_dict[network].append(data)
# add_to_dict(hom_0_list, hom_1_list, hetero_0_list, hetero_1_list, hetero_2_list, data)
data = {'network':None, 'test_case':None, 'injection_rate':None, 'injection_rate_slow':None, \
'avg_latency':None, 'worst_latency':None, 'throughput':None}
# print(het_t_rand_list)
# print(network_dict)
print_pretty(network_dict, test_case_list, injection_rate_list)