/
plot_figure_5_1.py
50 lines (37 loc) · 1.18 KB
/
plot_figure_5_1.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
from helper import *
import plot_defaults
from matplotlib.ticker import MaxNLocator
from pylab import figure
import os, re, string
parser = argparse.ArgumentParser()
parser.add_argument('--dir', '-d',
help="Directory where data exist",
required = True)
args = parser.parse_args()
dirs = [f for f in os.listdir(args.dir)]
data = []
for d in dirs:
plen = int(re.match('p-([0-9]+)', d).group(1))
testd = [f for f in os.listdir(os.path.join(args.dir, d))]
aggregated = 0.0
for test in testd:
file_path = os.path.join(args.dir, d, test, "result.txt")
with open(file_path, 'r') as result_file:
aggregated += float(result_file.readlines()[1].strip())
aggregated /= len(testd)
aggregated /= 1.5
data.append([plen, aggregated])
m.rc('figure')
fig = figure()
ax = fig.add_subplot(111)
def getkey(item):
return item[0]
data_sort = sorted(data, key=getkey)
xaxis = map(float, col(0, data_sort))
yaxis = map(float, col(1, data_sort))
ax.plot(xaxis, yaxis, lw=2)
plt.ylabel("Aggregated Normalized Bandwidth")
plt.xlabel("Inter-burst DoS Period(ms)")
plt.grid(True)
plt.tight_layout()
plt.savefig(args.dir + ".png")