Skip to content

Commit 8ef7716

Browse files
adeepkit01Viyom
authored andcommitted
updated python script
1 parent d0f44e0 commit 8ef7716

File tree

2 files changed

+79
-79
lines changed

2 files changed

+79
-79
lines changed

src/aqm-eval-suite/utils/drop_process.py

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,52 @@
44

55
scenario_name = sys.argv[1]
66
queuedisc_name = sys.argv[2]
7-
fname = 'aqm-eval-output/'+scenario_name+"/data/"+queuedisc_name+'-drop.dat'
8-
nfname = 'aqm-eval-output/'+scenario_name+"/data/new-"+queuedisc_name+'-drop.dat'
9-
f = open (fname ,"r")
10-
l = f.readlines ()
11-
l.sort ()
12-
f.close ()
7+
file_name = 'aqm-eval-output/'+scenario_name+"/data/"+queuedisc_name+'-drop.dat'
8+
new_file_name = 'aqm-eval-output/'+scenario_name+"/data/new-"+queuedisc_name+'-drop.dat'
9+
File = open (file_name ,"r")
10+
lines_read = File.readlines ()
11+
lines_read.sort ()
12+
File.close ()
1313
i=0
14-
d=[]
15-
a=[]
16-
F3 = []
17-
for m in l:
18-
if i == len(l)-1:
14+
data=[]
15+
inst_data=[]
16+
bucket = []
17+
for file_iterator in lines_read:
18+
if i == len(lines_read)-1:
1919
break
2020
i+=1
21-
if m.split(' ')[0] == l[i].split(' ')[0]:
22-
s1 = float(m.split(' ')[1])
23-
d.append(s1)
21+
if file_iterator.split(' ')[0] == lines_read[i].split(' ')[0]:
22+
temp_string = float(file_iterator.split(' ')[1])
23+
data.append(temp_string)
2424
else:
25-
d.sort ()
26-
j=1
25+
data.sort ()
26+
data_iterator=1
2727

28-
while j < len(d):
29-
a.append(d[j]-d[j-1])
30-
j+=1
31-
hist, bin_edges = np.histogram(a, normed=True, bins=10000, density=True)
28+
while data_iterator < len(data):
29+
inst_data.append(data[data_iterator]-data[data_iterator-1])
30+
data_iterator+=1
31+
hist, bin_edges = np.histogram(inst_data, normed=True, bins=10000, density=True)
3232
dx = bin_edges[1] - bin_edges[0]
33-
F1 = np.cumsum(hist)*dx
34-
F2 = [[0,0], [bin_edges[0], 0]]
35-
for k in range(len(F1)):
36-
F2.append([bin_edges[k+1], F1[k]])
37-
F3.append(F2)
38-
d=[]
33+
Function_uno = np.cumsum(hist)*dx
34+
Function_duo = [[0,0], [bin_edges[0], 0]]
35+
for k in range(len(Function_uno)):
36+
Function_duo.append([bin_edges[k+1], Function_uno[k]])
37+
bucket.append(Function_duo)
38+
data=[]
3939

40-
d.sort ()
41-
j = 1
42-
while j < len(d):
43-
a.append(d[j]-d[j-1])
44-
j+=1
45-
hist, bin_edges = np.histogram(a, normed=True, bins=10000, density=True)
40+
data.sort ()
41+
data_iterator = 1
42+
while data_iterator < len(data):
43+
inst_data.append(data[data_iterator]-data[data_iterator-1])
44+
data_iterator+=1
45+
hist, bin_edges = np.histogram(inst_data, normed=True, bins=10000, density=True)
4646
dx = bin_edges[1] - bin_edges[0]
47-
F1 = np.cumsum(hist)*dx
48-
F2 = [[0,0], [bin_edges[0], 0]]
49-
for k in range(len(F1)):
50-
F2.append([bin_edges[k+1], F1[k]])
51-
F3.append(F2)
52-
d=[]
47+
Function_uno = np.cumsum(hist)*dx
48+
Function_duo = [[0,0], [bin_edges[0], 0]]
49+
for k in range(len(Function_uno)):
50+
Function_duo.append([bin_edges[k+1], Function_uno[k]])
51+
bucket.append(Function_duo)
52+
data=[]
5353

5454
gnufile = 'aqm-eval-output/'+scenario_name+"/data/"+queuedisc_name+'-gnu-drop'
5555
gnu = open(gnufile, "w")
@@ -58,21 +58,21 @@
5858
gnu.write("set output \"aqm-eval-output/"+scenario_name+"/graph/"+queuedisc_name+"-drop.png\"\n set xlabel \"Time difference between two drops\"\nset ylabel \"CDF\"\nset grid\nshow grid\n")
5959

6060

61-
wfile = open (nfname ,"w")
61+
wfile = open (new_file_name ,"w")
6262

6363
flow = 1
64-
for x in F3:
64+
for x in bucket:
6565
wfile.write("\n\n#\"flow"+str(flow)+"\"\n")
6666
flow+=1
6767
for y in x:
6868
wfile.write (str(y[0])+" "+str(y[1])+"\n")
6969
wfile.close()
7070

71-
for j in range(len(F3)):
72-
if j == 0:
73-
gnu.write("plot \""+nfname+"\" i "+str(j)+" using 1:2 with lines smooth csplines title \"Flow "+str(j+1)+"\"")
71+
for data_iterator in range(len(bucket)):
72+
if data_iterator == 0:
73+
gnu.write("plot \""+new_file_name+"\" i "+str(data_iterator)+" using 1:2 with lines smooth csplines title \"Flow "+str(data_iterator+1)+"\"")
7474
else:
75-
gnu.write(", \""+nfname+"\" i "+str(j)+" using 1:2 with lines smooth csplines title \"Flow "+str(j+1)+"\"")
75+
gnu.write(", \""+new_file_name+"\" i "+str(data_iterator)+" using 1:2 with lines smooth csplines title \"Flow "+str(data_iterator+1)+"\"")
7676

7777
gnu.close()
7878
os.system("gnuplot "+gnufile)

src/aqm-eval-suite/utils/goodput_process.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,60 +3,60 @@
33

44
scenario_name = sys.argv[1]
55
queuedisc_name = sys.argv[2]
6-
fname = 'aqm-eval-output/'+scenario_name+"/data/"+queuedisc_name+'-goodput.dat'
7-
nfname = 'aqm-eval-output/'+scenario_name+"/data/new-"+queuedisc_name+'-goodput.dat'
8-
f = open (fname ,"r")
9-
l = f.readlines ()
10-
l.sort ()
11-
f.close ()
6+
file_name = 'aqm-eval-output/'+scenario_name+"/data/"+queuedisc_name+'-goodput.dat'
7+
new_file_name = 'aqm-eval-output/'+scenario_name+"/data/new-"+queuedisc_name+'-goodput.dat'
8+
File = open (file_name ,"r")
9+
lines_read = File.readlines ()
10+
lines_read.sort ()
11+
File.close ()
1212
i = 0
13-
d = []
14-
f = []
15-
g = []
16-
for m in l:
17-
if i == len(l)-1:
13+
data = []
14+
File = []
15+
inst_data = []
16+
for file_iterator in lines_read:
17+
if i == len(lines_read)-1:
1818
break
1919
i+=1
20-
if m.split(' ')[0] == l[i].split(' ')[0]:
21-
s1 = float(m.split(' ')[1])
22-
s2 = int((m.split(' ')[2]).replace('\n', ''))
23-
d.append([s1,s2])
20+
if file_iterator.split(' ')[0] == lines_read[i].split(' ')[0]:
21+
string_uno = float(file_iterator.split(' ')[1])
22+
string_duo = int((file_iterator.split(' ')[2]).replace('\n', ''))
23+
data.append([string_uno,string_duo])
2424
else:
25-
d.sort()
25+
data.sort()
2626
goodput_val = 0
2727
goodput_count = 0
2828
last_recorded = 0
29-
for a in d:
29+
for a in data:
3030
if a[0] - last_recorded < 0.1:
3131
goodput_val += a[1]
3232
goodput_count+=1
3333
else:
3434
last_recorded = a[0]
3535
if goodput_count>0:
36-
g.append([a[0], (goodput_val*1.0/a[0])])
36+
inst_data.append([a[0], (goodput_val*1.0/a[0])])
3737
last_recorded = a[0]
3838
if goodput_count>0:
39-
g.append([a[0], (goodput_val*1.0/a[0])])
40-
d = []
41-
f.append(g)
42-
g = []
39+
inst_data.append([a[0], (goodput_val*1.0/a[0])])
40+
data = []
41+
File.append(inst_data)
42+
inst_data = []
4343

44-
d.sort()
44+
data.sort()
4545
goodput_val = 0
4646
goodput_count = 0
4747
last_recorded = 0
48-
for a in d:
48+
for a in data:
4949
if a[0] - last_recorded < 0.1:
5050
goodput_val += a[1]
5151
goodput_count+=1
5252
else:
5353
last_recorded = a[0]
5454
if goodput_count>0:
55-
g.append([float("{0:.2f}".format(a[0])), (goodput_val*1.0/a[0])])
55+
inst_data.append([float("{0:.2f}".format(a[0])), (goodput_val*1.0/a[0])])
5656
last_recorded = a[0]
5757
if goodput_count>0:
58-
g.append([float("{0:.2f}".format(a[0])), (goodput_val*1.0/a[0])])
59-
f.append(g)
58+
inst_data.append([float("{0:.2f}".format(a[0])), (goodput_val*1.0/a[0])])
59+
File.append(inst_data)
6060

6161
st = ""
6262

@@ -67,28 +67,28 @@
6767
gnu.write("set output \"aqm-eval-output/"+scenario_name+"/graph/"+queuedisc_name+"-goodput.png\"\n set xlabel \"Time (Seconds)\" font \"Verdana\"\nset ylabel \"Goodput (Mbps)\" font \"Verdana,24\"\nset grid\nshow grid\nset key font \",18\"\n")
6868

6969

70-
wfile = open (nfname ,"w")
70+
wfile = open (new_file_name ,"w")
7171

7272
flow = 1
73-
for x in f:
73+
for x in File:
7474
wfile.write("\n\n#\"flow"+str(flow)+"\"\n")
7575
flow+=1
7676
for y in x:
7777
wfile.write (str(y[0])+" "+str(y[1]/(1024*128))+"\n")
7878
wfile.close()
7979

8080
if "RttFairness" in scenario_name:
81-
for j in range(len(f)):
81+
for j in range(len(File)):
8282
if j == 0:
83-
gnu.write("plot \""+nfname+"\" i "+str(j)+" using 1:2 with lines smooth csplines title \"Fixed Rtt Flow\"")
83+
gnu.write("plot \""+new_file_name+"\" i "+str(j)+" using 1:2 with lines smooth csplines title \"Fixed Rtt Flow\"")
8484
else:
85-
gnu.write(", \""+nfname+"\" i "+str(j)+" using 1:2 with lines smooth csplines title \"Variable Rtt Flow\"")
85+
gnu.write(", \""+new_file_name+"\" i "+str(j)+" using 1:2 with lines smooth csplines title \"Variable Rtt Flow\"")
8686
else:
87-
for j in range(len(f)):
87+
for j in range(len(File)):
8888
if j == 0:
89-
gnu.write("plot \""+nfname+"\" i "+str(j)+" using 1:2 with lines smooth csplines title \"Flow "+str(j+1)+"\"")
89+
gnu.write("plot \""+new_file_name+"\" i "+str(j)+" using 1:2 with lines smooth csplines title \"Flow "+str(j+1)+"\"")
9090
else:
91-
gnu.write(", \""+nfname+"\" i "+str(j)+" using 1:2 with lines smooth csplines title \"Flow "+str(j+1)+"\"")
91+
gnu.write(", \""+new_file_name+"\" i "+str(j)+" using 1:2 with lines smooth csplines title \"Flow "+str(j+1)+"\"")
9292

9393
gnu.close()
9494
os.system("gnuplot "+gnufile)

0 commit comments

Comments
 (0)