-
Notifications
You must be signed in to change notification settings - Fork 1
/
plot.py
80 lines (61 loc) · 1.96 KB
/
plot.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
#%%
#Place that folder in directory with all .dat files
#and run: wsl ls -1 | python plot.py
import numpy as np
import math
import matplotlib.pyplot as plt
import fileinput
interfaces = dict()
for line in fileinput.input():
line = line.rstrip()
filename = line
line = line.split('.')
if len(line) > 1:
if (line[1] == 'dat'):
with open(filename) as file:
i = 0
for ln in file.readlines():
ln = ln.rstrip().split()
try:
ln[2] = int(int(ln[2]) / 1000)
ln[3] = int(int(ln[3]) / 1000)
ln[0] = int(ln[0])
if ln[1] not in interfaces:
interfaces[ln[1]] = dict()
if ln[4] not in interfaces[ln[1]]:
interfaces[ln[1]][ln[4]] = dict()
interfaces[ln[1]][ln[4]][ln[0]] = ln[2], ln[3]
except:
print(f'DUPA at: {i} {filename}')
i += 1
def plot_fig(x, y, if_name, type):
plt.plot(x, y, label=dataset_name)
plt.legend()
plt.ylabel(f'Throughput {type} MB/s')
plt.xlabel(f'Time')
plt.xticks([])
plt.savefig(f'{if_name}_{type}.png')
for if_name in interfaces:
print(f'Plotting {if_name}')
interface = interfaces.get(if_name)
data = interface['optimal']
for dataset_name in interface:
data = interface.get(dataset_name)
time = list()
i = 0
rx = list()
tx = list()
for value in data:
tmp = data.get(value)
if tmp[0] == 1 or tmp[1] == 0:
continue
rx.append(tmp[0])
tx.append(tmp[1])
time.append(i)
i += 1
time = np.array(time)
tx = np.array(tx)
rx = np.array(rx)
plot_fig(time, rx, if_name, 'rx')
plt.clf()
print('Done')