Commit 8b4c3805 authored by Deathcrow's avatar Deathcrow

more statistics

parent 49dba4c8
......@@ -43,8 +43,25 @@ def clean_up():
time.sleep(1)
#def parse_dir(directory):
def qsort1(list):
"""Quicksort using list comprehensions"""
if list == []:
return []
else:
pivot = list[0]
lesser = qsort1([x for x in list[1:] if x < pivot])
greater = qsort1([x for x in list[1:] if x >= pivot])
return lesser + [pivot] + greater
def quantil(list,p):
length = len(list)
len_p = length * p
if math.ceil(len_p) == len_p:
return ((list[int(len_p)] + list[int(len_p + 1)]) / 2)
else:
return list[math.ceil(len_p)]
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
......@@ -52,7 +69,7 @@ signal.signal(signal.SIGTERM, signal_handler)
parser = argparse.ArgumentParser(description='Configure test environment.')
parser.add_argument('folders', nargs="*", default="./", help="Folder to search for files")
parser.add_argument('-m', '--mask')
parser.add_argument('-m', '--mask', default="")
args = parser.parse_args()
......@@ -74,7 +91,7 @@ bw_file_lines = 0
for folder in args.folders:
for path, dirs, files in os.walk(folder):
for file in files:
if file[:9] == "tcpprobe_":
if file[:9+len(args.mask)] == "tcpprobe_"+args.mask:
tcpprobe_file = open(path + "/" + file)
for line in tcpprobe_file:
line = line.split(" ")
......@@ -82,7 +99,7 @@ for folder in args.folders:
rtt_values_file.write(line[9]+'\n')
rtt_file_lines += 1
tcpprobe_file.close()
elif file[:3] == "bw_":
elif file[:3+len(args.mask)] == "bw_"+args.mask:
bw_file = open(path + "/" + file)
for line in bw_file:
line = line.split(" ")
......@@ -94,18 +111,88 @@ for folder in args.folders:
bw_values_file.seek(0)
rtt_values_file.seek(0)
avg_bw = sum( [ float(line) for line in bw_values_file ] ) / bw_file_lines
avg_rtt = sum( [ float(line) for line in rtt_values_file ] ) / rtt_file_lines
print("avg_bw: "+str(avg_bw))
print("avg_rtt: "+str(avg_rtt))
bw_values_file.seek(0)
rtt_values_file.seek(0)
std_deviation_bw = math.sqrt(1/(bw_file_lines - 1) * sum( [ (float(line)-avg_bw)**2 for line in bw_values_file ] ))
std_deviation_rtt = math.sqrt(1/(rtt_file_lines - 1) * sum( [ (float(line)-avg_rtt)**2 for line in rtt_values_file ] ))
print("std_deviation_bw: "+str(std_deviation_bw))
print("std_deviation_rtt: "+str(std_deviation_rtt))
def statify_list(sorted_list, n):
avg = sum( sorted_list ) / n
std_deviation = math.sqrt((1/(n - 1)) * sum( [ (value-avg)**2 for value in sorted_list ] ))
q_25 = quantil(sorted_list, 0.25)
q_75 = quantil(sorted_list, 0.75)
iqr = q_75 - q_25
bot = sorted_list[0]
top = sorted_list[len(sorted_list) - 1]
whisker_bot = bot
for value in sorted_list:
if value >= (q_25 - iqr*1.5):
whisker_bot = value
break
whisker_top = top
for value in reversed(sorted_list):
if value <= (q_75 + iqr*1.5):
whisker_top = value
break
percent_under_whisker = 0
count = 0
for value in sorted_list:
if value < whisker_bot:
count += 1
else:
percent_under_whisker = (count / n) * 100
break
count = 0
for value in reversed(sorted_list):
if value > whisker_top:
count += 1
else:
percent_over_whisker = (count / n) * 100
break
print("Average:\t"+str(avg))
print("Std. deviation:\t"+str(std_deviation))
print("0.25 Quantil:\t"+str(q_25))
print("0.75 Quantil:\t"+str(q_75))
print("IQR:\t\t"+str(iqr))
print("bot. whisker:\t"+str(whisker_bot))
print("top whisker:\t"+str(whisker_top))
print("% < whisker:\t"+str(percent_under_whisker))
print("% > whisker:\t"+str(percent_over_whisker))
#return list with extreme outliers removed
for value in sorted_list:
if value < (q_25 - iqr*3.0):
del sorted_list[0]
else:
break
for value in reversed(sorted_list):
if value > (q_75 + iqr*3.0):
del sorted_list[len(sorted_list)-1]
else:
break
print("Std. deviation without outliers: "+str(math.sqrt((1/(n - 1)) * sum( [ (value-avg)**2 for value in sorted_list ] ))))
return sorted_list
sorted_bw = sorted([ float(line) for line in bw_values_file ])
sorted_rtt = sorted([ float(line) for line in rtt_values_file ])
print("Bandwidth: ")
print("=============================")
sorted_bw = statify_list(sorted_bw, len(sorted_bw))
print("")
print("Round Trip Time: ")
print("=============================")
sorted_rtt = statify_list(sorted_rtt, len(sorted_rtt))
from pylab import *
boxplot(sorted_bw)
show()
boxplot(sorted_rtt)
show()
#rtt_q_25 = quantil(sorted_rtt, 0.25)
#rtt_q_75 = quantil(sorted_rtt, 0.75)
#rtt_iqr = rtt_q_75 - rtt_q_25
#print(bw_values_file.read())
#print(bw_file_lines)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment