From 18c9ca6d79683d36e6687e7a693ec08903d525ac Mon Sep 17 00:00:00 2001 From: 0xFugue <119708655+0xFugue@users.noreply.github.com> Date: Wed, 23 Aug 2023 00:18:51 +0530 Subject: [PATCH] avg view fin times for multiple sims --- scripts/analysis.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/scripts/analysis.py b/scripts/analysis.py index 4bb57d0..44b8198 100644 --- a/scripts/analysis.py +++ b/scripts/analysis.py @@ -9,6 +9,7 @@ import logging as log from pathlib import Path import matplotlib.pyplot as plt from os import walk +from collections import defaultdict def read_json(fname): with open(fname) as f: @@ -42,6 +43,8 @@ def compute_view_finalisation_times(df, conf, oprefix, tag="tag", plot=False, ep log.debug(f'{start_view}({start_idx}), {end_view}({end_idx}) : {end_step} - {start_step} = {view2fin_time[start_view]}') if not plot: + if not view2fin_time: + return conf["views_count"] return sum(view2fin_time.values())/len(view2fin_time.values()) fig, axes = plt.subplots(1, 1, layout='constrained', sharey=False) @@ -87,16 +90,23 @@ def views(ctx: typer.Context, help="Set the output prefix for the plots") ): - fin = [] + tag2vfins = {} conf_fnames = next(walk(f'{path}/configs'), (None, None, []))[2] # [] if no file for conf in conf_fnames: - prefix = os.path.splitext(os.path.basename(conf))[0] - conf = read_json(f'{path}/configs/{conf}') - df = read_csv(f'{path}/output/{prefix}.csv') - res = compute_view_finalisation_times(df, conf, oprefix, tag, plot=True, epoch=True) - fin.append(res) - + tag = os.path.splitext(os.path.basename(conf))[0] + tag2vfins[tag] = {} + conf, df = read_json(f'{path}/configs/{conf}'), read_csv(f'{path}/output/output/{tag}.csv') + simtype = conf["stream_settings"]["path"].split("/")[1].split("_")[0] + res = compute_view_finalisation_times(df, conf, oprefix, tag, plot=False, epoch=True) + if simtype == "tree": + num_nodes = conf["node_count"] + tag2vfins[tag][num_nodes] = res + else: + max_depth = conf["overlay_settings"]["branch_depth"] + tag2vfins[tag][max_depth] = res + print(tag, res) + print(tag2vfins) @app.command() def other_commands():