diff --git a/scripts/jantoran.py b/scripts/jantoran.py index 8d1dbc9..a0d5df0 100755 --- a/scripts/jantoran.py +++ b/scripts/jantoran.py @@ -1,22 +1,33 @@ #!/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']['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 compute_circuit_distri(s): - s['current']['lats'] = l = sorted(s['current']['lats']) - s['current']['distri'] = d = {} - perc = lambda p: l[round(p * (len(l) - 1))] - for x in [0, 0.25, 0.5, 0.75, 0.99, 0.999, 1]: - d[str(x)] = perc(x) + l = sorted(s['current']['lats']) + s['current']['distri'] = tool_distri(l, default_perc) def compute_interval_distri(s): - for inter, val in s['per_interval']: - s['per_interval_res'][inter] = {} - s['per_interval_res'][inter]['agg'] = sorted([].extend([ elem['lats'] for elem in val])) + print(" + latency distribution for given packet freq.") + to_process = len(s['per_interval']) + processed = 0 + for inter, val in s['per_interval'].items(): + progress = round(processed / to_process * 100) + print(f"{progress}%", end="\r") + x = sorted(functools.reduce(lambda acc, v: acc + v['lats'], val, [])) + s['per_interval_res'][inter] = tool_distri(x, default_perc) + processed += 1 def extract_measlat(log, s): s['current']['max_pkt'] = 0 @@ -41,14 +52,14 @@ def extract_folder(p, s): extract_measlat(p + '/log/client-measlat-stdout.log', s) compute_failure(s) - compute_circuit_distri(s) if s['current']['interval'] == 40 + compute_circuit_distri(s) if s['current']['interval'] == 40 else None def categorize(folder, s): s[folder] = s['current'] - i = s['current']['interval'] + i = str(s['current']['interval']) if i not in s['per_interval']: s['per_interval'][i] = [] - s['per_interval'][i].append(current) + s['per_interval'][i].append(s['current']) def extract(p, s): item_count = functools.reduce(lambda acc, prev: acc + 1, os.listdir(p), 0) @@ -65,7 +76,7 @@ def extract(p, s): print("done") def compute_global(s): - print("computing global...") + print("computing on global values...") compute_interval_distri(s) def analyze_failure(s): @@ -88,7 +99,7 @@ def analyze(s): print("analyzing...") analyze_failure(s) - state = {'failure': {}, 'per_interval': {}, 'per_interval_res': {}} +state = {'failure': {}, 'per_interval': {}, 'per_interval_res': {}} extract(sys.argv[1], state) compute_global(state) analyze(state)