forked from UNN/2026-rff_mp
[3] 1-st exersize
This commit is contained in:
parent
2a707b6dd8
commit
1bd7783f31
|
|
@ -226,4 +226,30 @@ def run_experiments():
|
||||||
writer.writerows(all_results)
|
writer.writerows(all_results)
|
||||||
|
|
||||||
print(f"\nРезультаты сохранены в {filepath}")
|
print(f"\nРезультаты сохранены в {filepath}")
|
||||||
return all_results
|
return all_results
|
||||||
|
|
||||||
|
def plot_results(csv_path="docs/data/results.csv"):
|
||||||
|
import pandas as pd
|
||||||
|
df = pd.read_csv(csv_path)
|
||||||
|
summary = df.groupby(["Структура", "Режим", "Операция"])["Время (сек)"].mean().reset_index()
|
||||||
|
|
||||||
|
for op in ["вставка", "поиск", "удаление"]:
|
||||||
|
op_data = summary[summary["Операция"] == op]
|
||||||
|
plt.figure(figsize=(10, 6))
|
||||||
|
x_labels = []
|
||||||
|
y_values = []
|
||||||
|
for _, row in op_data.iterrows():
|
||||||
|
label = f"{row['Структура']}\n({row['Режим']})"
|
||||||
|
x_labels.append(label)
|
||||||
|
y_values.append(row["Время (сек)"])
|
||||||
|
plt.bar(x_labels, y_values, color=['#4C72B0', '#55A868', '#C44E52'] * 2)
|
||||||
|
plt.title(f"Среднее время операции: {op}")
|
||||||
|
plt.ylabel("Время (сек)")
|
||||||
|
plt.xticks(rotation=45)
|
||||||
|
plt.tight_layout()
|
||||||
|
plt.savefig(f"docs/data/graph_{op}.png")
|
||||||
|
print(f"График сохранён: docs/data/graph_{op}.png")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
run_experiments()
|
||||||
|
plot_results()
|
||||||
Loading…
Reference in New Issue
Block a user