2020-01-20 10:31:59 +00:00
|
|
|
#!/usr/bin/python3
|
|
|
|
import os,sys,re,functools
|
|
|
|
|
|
|
|
default_perc = [0, 0.25, 0.5, 0.75, 0.99, 0.999, 1]
|
|
|
|
|
|
|
|
def tool_distri(arr, perc):
|
|
|
|
r = {}
|
|
|
|
for p in perc:
|
|
|
|
r[str(p)] = arr[round(p * (len(arr) - 1))]
|
|
|
|
return r
|
|
|
|
|
|
|
|
def compute_failure(s):
|
|
|
|
it = s['current']['strat']
|
|
|
|
if it not in s['failure']: s['failure'][it] = []
|
|
|
|
s['failure'][it].append(round(s['current']['max_pkt'] * s['current']['interval'] / 1000 / 60))
|
|
|
|
return True
|
|
|
|
|
|
|
|
def extract_measlat(log, s):
|
|
|
|
s['current']['max_pkt'] = 0
|
|
|
|
s['current']['lats'] = []
|
|
|
|
try:
|
|
|
|
with open(log) as f:
|
|
|
|
for l in f:
|
|
|
|
x = re.search(r'Packet (\d+) latency (\d+)µs with', l)
|
|
|
|
if x:
|
|
|
|
pkt = int(x.groups()[0])
|
|
|
|
lat = int(x.groups()[1])
|
|
|
|
s['current']['max_pkt'] = max(s['current']['max_pkt'], pkt)
|
|
|
|
#s['current']['lats'].append(lat)
|
|
|
|
return True
|
|
|
|
except:
|
|
|
|
return False
|
|
|
|
|
|
|
|
def extract_info(inf, s):
|
|
|
|
try:
|
|
|
|
with open(inf) as f:
|
|
|
|
full = ''.join(f.readlines())
|
2020-01-20 10:53:55 +00:00
|
|
|
w = re.search(r'identifier=jan_', full)
|
|
|
|
if not w: return False
|
2020-01-20 10:31:59 +00:00
|
|
|
x = re.search(r'server= (\S+) (\d+) (\d+) \d+ (\d+ (\S+))?', full)
|
|
|
|
if x:
|
|
|
|
s['current']['strat'] = x.groups()[0]
|
|
|
|
if x.groups()[4] != None:
|
|
|
|
y = re.search(r'tick_tock=(\d)', x.groups()[4])
|
|
|
|
if y:
|
|
|
|
s['current']['strat'] += "-ticktock" if y.groups()[0] == '1' else "-duplicate"
|
|
|
|
s['current']['npkt'] = int(x.groups()[1])
|
|
|
|
s['current']['interval'] = int(x.groups()[2])
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
print("parse error for",inf)
|
|
|
|
return False
|
|
|
|
except Exception as e:
|
|
|
|
print("read error", inf, e)
|
|
|
|
return False
|
|
|
|
|
|
|
|
def extract_folder(p, s):
|
|
|
|
return extract_info(p + '/info.txt', s) and extract_measlat(p + '/log/client-measlat-stdout.log', s) and compute_failure(s)
|
|
|
|
|
|
|
|
def categorize(folder, s):
|
|
|
|
s[folder] = s['current']
|
|
|
|
|
|
|
|
i = str(s['current']['strat'])
|
|
|
|
if i not in s['per_strat']: s['per_strat'][i] = []
|
|
|
|
s['per_strat'][i].append(s['current'])
|
|
|
|
|
|
|
|
def extract(p, s):
|
|
|
|
item_count = functools.reduce(lambda acc, prev: acc + 1, os.listdir(p), 0)
|
|
|
|
|
|
|
|
counter = 0
|
|
|
|
print("extracting...")
|
|
|
|
for folder in os.listdir(p):
|
|
|
|
s['current'] = {}
|
|
|
|
extract_folder(p + '/' + folder, s) and categorize(folder, s)
|
|
|
|
counter += 1
|
|
|
|
progress = round(counter / item_count * 100)
|
|
|
|
print(f"{progress}%", end="\r")
|
|
|
|
print("done")
|
|
|
|
|
|
|
|
def analyze_failure(s):
|
|
|
|
with open('jan2_failure.csv', 'w') as f:
|
|
|
|
f.write(f"strat,duration,ecdf\n")
|
|
|
|
for strat, v in s['failure'].items():
|
|
|
|
v = sorted(v)
|
|
|
|
total = len(v)
|
|
|
|
score = 0
|
|
|
|
f.write(f"{strat},0,0\n")
|
|
|
|
for idx,e in enumerate(v,start=1):
|
|
|
|
if e >= 90:
|
|
|
|
f.write(f"{strat},90,{score}\n")
|
|
|
|
break
|
|
|
|
score = idx/total
|
|
|
|
f.write(f"{strat},{e},{score}\n")
|
|
|
|
|
|
|
|
def analyze(s):
|
|
|
|
print("analyzing...")
|
|
|
|
analyze_failure(s)
|
|
|
|
|
|
|
|
state = {'failure': {}, 'per_strat': {}, 'per_interval_res': {}, 'per_circuit_res': []}
|
|
|
|
extract(sys.argv[1], state)
|
|
|
|
analyze(state)
|