diff --git a/plot.py b/plot.py index 10018ac..78bc618 100644 --- a/plot.py +++ b/plot.py @@ -14,6 +14,16 @@ def plottable(log: list[tuple[float, int]]): return np.array([[], []]) +def format_params(params) -> str: + match params: + case dict(): + return '{' + ' '.join(f'{key}={format_params(value)}' for key, value in params.items()) + '}' + case list(): + return f'[{" ".join(format_params(value) for value in params)}]' + case _: + return json.dumps(params) + + def plot(fn: str): plt.rcParams['figure.figsize'] = [16, 9] plt.style.use('dark_background') @@ -26,7 +36,7 @@ def plot(fn: str): title = fn if (params := jsonified.pop('params', None)) is not None: - title += f' {":".join(map(str, params))}' + title += f' {format_params(params)}' plt.title(title) def logplot(plot_function, metric: str, **kwargs): @@ -36,15 +46,18 @@ def plot(fn: str): logplot(plt.plot, 'DelayedResolver:sleep:concurrency') logplot(plt.plot, 'ActiveBinaryTree:add:concurrency') logplot(plt.plot, 'ActiveBinaryTree:contains:concurrency') + logplot(plt.plot, 'FlowStandard:verify_subset:concurrency') logplot(plt.plot, 'Stack:list:concurrency') logplot(plt.scatter, 'ActiveBinaryTree:add:entry', c='tomato', zorder=100, s=.5) logplot(plt.scatter, 'ActiveBinaryTree:add:exit', c='gold', zorder=99, s=.5) plt.legend() plt.show() + plt.clf() if __name__ == '__main__': + Path('trace').mkdir(exist_ok=True) if Path('trace/latest.json').exists(): plot('trace/latest.json') for fp in list(Path('trace').glob('*.json')):