From 6998598f2900c6990abdfa2394ce043bc6f7323a Mon Sep 17 00:00:00 2001 From: Lorenzo Venerandi Date: Fri, 21 Feb 2025 01:18:25 +0100 Subject: [PATCH] added script to plot metrics --- plot_metrics.py | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 plot_metrics.py diff --git a/plot_metrics.py b/plot_metrics.py new file mode 100644 index 0000000..19e1299 --- /dev/null +++ b/plot_metrics.py @@ -0,0 +1,54 @@ +import matplotlib.pyplot as plt +import yaml + +# Function to read and parse the file +def read_metrics(file_path): + with open(file_path, 'r') as file: + data = yaml.safe_load(file) + return data['runs'] + +# Read metrics from the file +file_path = 'project/metrics.yaml' # Replace with the correct file path +runs = read_metrics(file_path) + +# Extracting values +n_tasks = [run['n_task'] for run in runs] +build_times = [float(run['build']['components_build_time']) for run in runs] +gen_times = [float(run['code_gen']['gen_time']) for run in runs] +deploy_times = [float(run['deploy']['components_deploy_time']) for run in runs] + +# Plotting Build Time +plt.figure(figsize=(8, 6)) +ax = plt.gca() # Get current axis +p = ax.bar(n_tasks, build_times, color='b') +ax.bar_label(p, label_type='edge') +ax.set_title('Build Time') +ax.set_xlabel('Number of Tasks') +ax.set_ylabel('Build Time (seconds)') +plt.tight_layout() +plt.savefig('build_time_plot.png') # Save the plot as an image +plt.close() + +# Plotting Code Generation Time +plt.figure(figsize=(8, 6)) +ax = plt.gca() # Get current axis +p = ax.bar(n_tasks, gen_times, color='g') +ax.bar_label(p, label_type='edge') +ax.set_title('Code Generation Time') +ax.set_xlabel('Number of Tasks') +ax.set_ylabel('Generation Time (seconds)') +plt.tight_layout() +plt.savefig('gen_time_plot.png') # Save the plot as an image +plt.close() + +# Plotting Deployment Time +plt.figure(figsize=(8, 6)) +ax = plt.gca() # Get current axis +p = ax.bar(n_tasks, deploy_times, color='r') +ax.bar_label(p, label_type='edge') +ax.set_title('Deployment Time') +ax.set_xlabel('Number of Tasks') +ax.set_ylabel('Deployment Time (seconds)') +plt.tight_layout() +plt.savefig('deploy_time_plot.png') # Save the plot as an image +plt.close() \ No newline at end of file