forked from mtusi2026/mtusi2026lab3
53 lines
2.2 KiB
Python
53 lines
2.2 KiB
Python
import pandas as pd
|
|
import matplotlib.pyplot as plt
|
|
import os
|
|
|
|
# Создаем папку, если ее нет
|
|
os.makedirs('evidence/lab3/charts', exist_ok=True)
|
|
|
|
# Загружаем данные из CSV
|
|
csv_path = 'evidence/lab3/series-summary.csv'
|
|
if not os.path.exists(csv_path):
|
|
print(f"ОШИБКА: Файл {csv_path} не найден! Сначала создайте его.")
|
|
exit(1)
|
|
|
|
df = pd.read_csv(csv_path)
|
|
|
|
# --- ГРАФИК 1: RPS от числа реплик (Серия A) ---
|
|
df_a = df[df['series'] == 'A'].sort_values('replicas')
|
|
plt.figure(figsize=(8, 5))
|
|
plt.plot(df_a['replicas'], df_a['successful_rps'], marker='o', linestyle='-', color='red', linewidth=2, markersize=8)
|
|
plt.title('Series A: RPS vs Replicas (Fixed 2 CPU)', fontsize=14)
|
|
plt.xlabel('Number of Replicas', fontsize=12)
|
|
plt.ylabel('Successful RPS', fontsize=12)
|
|
plt.xticks(df_a['replicas'])
|
|
plt.grid(True, linestyle='--', alpha=0.7)
|
|
plt.savefig('evidence/lab3/charts/seriesA-rps-vs-replicas.png', bbox_inches='tight')
|
|
plt.close()
|
|
|
|
# --- ГРАФИК 2: RPS от суммарного CPU (Серия B) ---
|
|
df_b = df[df['series'] == 'B'].sort_values('total_cpu')
|
|
plt.figure(figsize=(8, 5))
|
|
plt.plot(df_b['total_cpu'], df_b['successful_rps'], marker='s', linestyle='-', color='blue', linewidth=2, markersize=8)
|
|
plt.title('Series B: RPS vs Total CPU (2 Replicas)', fontsize=14)
|
|
plt.xlabel('Total CPU Cores', fontsize=12)
|
|
plt.ylabel('Successful RPS', fontsize=12)
|
|
plt.xticks(df_b['total_cpu'])
|
|
plt.grid(True, linestyle='--', alpha=0.7)
|
|
plt.savefig('evidence/lab3/charts/seriesB-rps-vs-cpu.png', bbox_inches='tight')
|
|
plt.close()
|
|
|
|
# --- ГРАФИК 3: Сравнение p95 ---
|
|
plt.figure(figsize=(10, 5))
|
|
# Красим столбцы: серия А - красные, серия B - синие
|
|
colors = ['red' if s == 'A' else 'blue' for s in df['series']]
|
|
|
|
plt.bar(df['config'], df['p95_ms'], color=colors)
|
|
plt.title('p95 Latency by Configuration', fontsize=14)
|
|
plt.xlabel('Configuration', fontsize=12)
|
|
plt.ylabel('p95 Latency (ms)', fontsize=12)
|
|
plt.grid(axis='y', linestyle='--', alpha=0.7)
|
|
plt.savefig('evidence/lab3/charts/comparison-p95.png', bbox_inches='tight')
|
|
plt.close()
|
|
|
|
print("✅ Графики успешно созданы из series-summary.csv в evidence/lab3/charts/") |