Generate files

This commit is contained in:
Quentin Dufour 2020-01-14 11:09:52 +00:00
parent ef26caaf57
commit 5ebbfcd6e3

View file

@ -1,12 +1,59 @@
#!/usr/bin/python3
import os,sys
import os,sys,re,functools
def parse_folder(p):
with open(p + '/info.txt') as f:
print(f.readlines())
def compute_failure(s):
it = s['current']['interval']
if it not in s['failure']: s['failure'][it] = []
s['failure'][it].append(round(s['current']['max_pkt'] * s['current']['interval'] / 1000 / 60))
def parse_out(p):
def extract_measlat(log, s):
with open(log) as f:
for l in f:
x = re.search(r'Packet (\d+) latency (\d+)µs with', l)
if x:
s['current']['max_pkt'] = int(x.groups()[0])
def extract_info(inf, s):
with open(inf) as f:
full = ''.join(f.readlines())
x = re.search(r'orig-server (\d+) (\d+) \d+', full)
s['current']['npkt'] = int(x.groups()[0])
s['current']['interval'] = int(x.groups()[1])
def extract_folder(p, s):
extract_info(p + '/info.txt', s)
extract_measlat(p + '/log/client-measlat-stdout.log', s)
compute_failure(s)
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):
parse_folder(p + '/' + folder)
s['current'] = {}
extract_folder(p + '/' + folder, s)
s[folder] = s['current']
counter += 1
progress = round(counter / item_count * 100)
print(f"{progress}%", end="\r")
print("done")
parse_out(sys.argv[1])
def analyze_failure(s):
print(f"rate,duration")
for k, v in s['failure'].items():
rate = round(1000 / k)
for e in v:
print(f"{rate},{e}")
def analyze(s):
print("analyzing...")
analyze_failure(s)
state = {'failure': {}}
extract(sys.argv[1], state)
analyze(state)
#for key, value in state.items():
# print(value)