From fa1cf50cfd0b3eee68910f3738cfdd756aba8adf Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Fri, 24 Jan 2020 10:05:00 +0000 Subject: [PATCH] WIP jantoran --- scripts/jantoran_2.py | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/scripts/jantoran_2.py b/scripts/jantoran_2.py index ddb4a00..3ca6963 100755 --- a/scripts/jantoran_2.py +++ b/scripts/jantoran_2.py @@ -9,6 +9,24 @@ def tool_distri(arr, perc): r[str(p)] = arr[round(p * (len(arr) - 1))] return r +def compute_dropped(s): + s['current']['missing'] = [] + start = 0 + state = "BROKEN" + for missing_pkt in range(s['current']['npkt']+1): + if s['current']['crible'][missing_pkt] and state == 'WORKING': + state = 'BROKEN' + start = missing_pkt + elif (not s['current']['crible'][missing_pkt]) and state == 'BROKEN': + state = 'WORKING' + s['current']['missing'].append((start, missing_pkt-1,missing_pkt-start)) + + if state == 'BROKEN': + s['current']['missing'].append((start, s['current']['npkt'], 1+s['current']['npkt']-start)) + + print(s['current']['missing']) + return True + def compute_failure(s): it = (s['current']['strat'], s['current']['mode']) if it not in s['failure']: s['failure'][it] = [] @@ -17,7 +35,7 @@ def compute_failure(s): def extract_measlat(log, s): s['current']['max_pkt'] = 0 - s['current']['lats'] = [] + s['current']['crible'] = [True] * (s['current']['npkt']+1) try: with open(log) as f: for l in f: @@ -26,9 +44,10 @@ def extract_measlat(log, s): 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) + if pkt <= s['current']['npkt']: s['current']['crible'][pkt] = False return True - except: + except Exception as e: + print("read error", e) return False def extract_info(inf, s): @@ -56,7 +75,11 @@ def extract_info(inf, s): 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) + return \ + extract_info(p + '/info.txt', s) and \ + extract_measlat(p + '/log/client-measlat-stdout.log', s) and \ + compute_failure(s) and \ + compute_dropped(s) def categorize(folder, s): s[folder] = s['current'] @@ -64,6 +87,7 @@ def categorize(folder, s): i = (s['current']['strat'], s['current']['mode']) if i not in s['per_strat']: s['per_strat'][i] = [] s['per_strat'][i].append(s['current']) + return True def extract(p, s): item_count = functools.reduce(lambda acc, prev: acc + 1, os.listdir(p), 0) @@ -72,7 +96,9 @@ def extract(p, s): print("extracting...") for folder in os.listdir(p): s['current'] = {} - extract_folder(p + '/' + folder, s) and categorize(folder, s) + extract_folder(p + '/' + folder, s) and \ + categorize(folder, s) or \ + print(f"An error occured with {folder}") counter += 1 progress = round(counter / item_count * 100) print(f"{progress}%", end="\r")