mirror of
https://github.com/Lore09/Tesi-Magistrale.git
synced 2025-12-19 04:14:35 +00:00
moved plots to utils
This commit is contained in:
31
utils/plot-startup.py
Normal file
31
utils/plot-startup.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import matplotlib.pyplot as plt
|
||||||
|
import seaborn as sns
|
||||||
|
import random
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
# Genera i dati mock
|
||||||
|
data = [{"tempo di esecuzione": round(random.gauss(23, 1), 3)} for _ in range(9)]
|
||||||
|
df = pd.DataFrame(data)
|
||||||
|
|
||||||
|
# Creazione del boxplot con grafico più largo e barra più stretta
|
||||||
|
plt.figure(figsize=(10, 6)) # Grafico più largo
|
||||||
|
ax = sns.boxplot(y=df["tempo di esecuzione"], width=0.3, flierprops={"marker": "o", "color": "red", "markersize": 8}, color="lightgreen")
|
||||||
|
|
||||||
|
# Calcolo della media
|
||||||
|
mean_value = df["tempo di esecuzione"].mean()
|
||||||
|
|
||||||
|
# Aggiungi il testo della media alla base
|
||||||
|
plt.text(0, 0, f'Media: {mean_value:.2f}', ha='center', va='bottom', fontsize=14, fontweight='bold', color="black")
|
||||||
|
|
||||||
|
# Imposta i label con font più grande
|
||||||
|
plt.ylabel("Downtime (s)", fontsize=14)
|
||||||
|
plt.xticks([]) # Rimuove i tick sull'asse X
|
||||||
|
plt.yticks(fontsize=12)
|
||||||
|
|
||||||
|
# Mostra griglia leggera
|
||||||
|
plt.grid(axis='y', linestyle='--', alpha=0.6)
|
||||||
|
|
||||||
|
# Salva il plot
|
||||||
|
plt.tight_layout()
|
||||||
|
plt.savefig("benchmark/boxplot_failover.png")
|
||||||
|
plt.show()
|
||||||
@@ -28,12 +28,12 @@ def read_metrics(file_path, label):
|
|||||||
return extracted_data
|
return extracted_data
|
||||||
|
|
||||||
# Paths for the two metric files
|
# Paths for the two metric files
|
||||||
file_path_1 = 'project/metrics.yaml' # First metrics file
|
file_path_1 = 'res/metrics/metrics-parallel-nats.yaml' # First metrics file
|
||||||
file_path_2 = 'auga/metrics.yaml' # Second metrics file
|
file_path_2 = 'res/metrics/metrics-sequential.yaml' # Second metrics file
|
||||||
|
|
||||||
# Read and combine the data
|
# Read and combine the data
|
||||||
data1 = read_metrics(file_path_1, 'Parallel')
|
data1 = read_metrics(file_path_1, 'Esecuzione Parallelizzata')
|
||||||
data2 = read_metrics(file_path_2, 'Sequential')
|
data2 = read_metrics(file_path_2, 'Esecuzione Sequenziale')
|
||||||
|
|
||||||
df = pd.DataFrame(data1 + data2)
|
df = pd.DataFrame(data1 + data2)
|
||||||
|
|
||||||
@@ -71,15 +71,21 @@ def plot_lineplot(metric, filename):
|
|||||||
def plot_barplot(metric, filename):
|
def plot_barplot(metric, filename):
|
||||||
subset = df[df['Type'] == metric]
|
subset = df[df['Type'] == metric]
|
||||||
plt.figure(figsize=(10, 6))
|
plt.figure(figsize=(10, 6))
|
||||||
sns.barplot(x='Task', y='Time', hue='Source', data=subset, errorbar=('ci', 95))
|
|
||||||
|
sns.barplot(x='Task', y='Time', hue='Source', data=subset, errorbar=('ci', 95), palette=['salmon', 'skyblue'])
|
||||||
|
|
||||||
|
plt.xlabel('Task', fontsize=14) # Aumenta la dimensione del font dell'asse X
|
||||||
|
plt.ylabel('Time (seconds)', fontsize=14) # Aumenta la dimensione del font dell'asse Y
|
||||||
|
plt.xticks(fontsize=12) # Modifica la dimensione del font dei tick dell'asse X
|
||||||
|
plt.yticks(fontsize=12) # Modifica la dimensione del font dei tick dell'asse Y
|
||||||
|
plt.legend(title='Source', title_fontsize=14, fontsize=12) # Modifica il font della legenda
|
||||||
|
|
||||||
plt.ylabel('Time (seconds)')
|
|
||||||
plt.grid(True, linestyle='--', alpha=0.7)
|
plt.grid(True, linestyle='--', alpha=0.7)
|
||||||
plt.legend(title='Source')
|
|
||||||
plt.tight_layout()
|
plt.tight_layout()
|
||||||
plt.savefig(f'benchmark/{filename}')
|
plt.savefig(f'benchmark/{filename}')
|
||||||
plt.close()
|
plt.close()
|
||||||
|
|
||||||
|
|
||||||
# Generate plots for each metric
|
# Generate plots for each metric
|
||||||
metrics = ['Build Time', 'Generation Time', 'Deployment Time', 'Total Time']
|
metrics = ['Build Time', 'Generation Time', 'Deployment Time', 'Total Time']
|
||||||
filenames = ['build_time', 'gen_time', 'deploy_time', 'total_time']
|
filenames = ['build_time', 'gen_time', 'deploy_time', 'total_time']
|
||||||
Reference in New Issue
Block a user