update log paths
This commit is contained in:
+10
-7
@@ -1,6 +1,7 @@
|
||||
CXX = g++
|
||||
CXXFLAGS = -O3 -std=c++17 -pthread
|
||||
TARGET = lab2
|
||||
OUT_DIR = out
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
@@ -8,15 +9,17 @@ $(TARGET): main.cpp
|
||||
$(CXX) $(CXXFLAGS) main.cpp -o $(TARGET)
|
||||
|
||||
run_all: $(TARGET)
|
||||
@mkdir -p out/timelines
|
||||
@echo "1. Generating Timelines (N=1000, Threshold=10)..."
|
||||
./$(TARGET) 1000 2 10 > out/timelines/log_t2.txt
|
||||
./$(TARGET) 1000 4 10 > out/timelines/log_t4.txt
|
||||
python3 exporter.py out/timelines/log_t2.txt out/timelines/
|
||||
python3 exporter.py out/timelines/log_t4.txt out/timelines/
|
||||
@mkdir -p $(OUT_DIR)/{pics,logs}
|
||||
@echo "1. Generating Timelines (Logs and Pics into $(OUT_DIR)/)..."
|
||||
# Запуск и перенаправление логов в out/
|
||||
./$(TARGET) 1000 2 10 > $(OUT_DIR)/logs/log_t2.txt
|
||||
./$(TARGET) 1000 4 10 > $(OUT_DIR)/logs/log_t4.txt
|
||||
# Генерация графиков из логов в out/pics/
|
||||
python3 exporter.py $(OUT_DIR)/logs/log_t2.txt $(OUT_DIR)/pics
|
||||
python3 exporter.py $(OUT_DIR)/logs/log_t4.txt $(OUT_DIR)/pics
|
||||
|
||||
@echo "2. Generating Efficiency Benchmark..."
|
||||
python3 benchmark.py
|
||||
|
||||
clean:
|
||||
rm -rf $(TARGET) *.txt out/
|
||||
rm -rf $(TARGET) $(OUT_DIR)
|
||||
|
||||
+9
-14
@@ -30,39 +30,34 @@ def build_benchmark():
|
||||
|
||||
plt.figure(figsize=(12, 5))
|
||||
|
||||
# График времени
|
||||
plt.subplot(1, 2, 1)
|
||||
plt.plot(thread_counts, times, "o-", color="blue", label="Фактическое время")
|
||||
plt.xlabel("Кол-во потоков (0 = посл.)")
|
||||
plt.ylabel("Время выполнения (сек)")
|
||||
plt.title("Зависимость времени от потоков")
|
||||
plt.xlabel("Потоки")
|
||||
plt.ylabel("Время (сек)")
|
||||
plt.title("Время выполнения")
|
||||
plt.grid(True)
|
||||
plt.legend()
|
||||
|
||||
# График ускорения
|
||||
plt.subplot(1, 2, 2)
|
||||
t_seq = times[0]
|
||||
speedup = [t_seq / x if x > 0 else 1 for x in times]
|
||||
plt.plot(thread_counts, speedup, "s-", color="green", label="Ускорение (S)")
|
||||
plt.plot(thread_counts, speedup, "s-", color="green", label="Ускорение")
|
||||
plt.plot(
|
||||
thread_counts,
|
||||
[x if x > 0 else 1 for x in thread_counts],
|
||||
"--",
|
||||
color="red",
|
||||
alpha=0.5,
|
||||
label="Идеал",
|
||||
)
|
||||
plt.xlabel("Кол-во потоков")
|
||||
plt.ylabel("S = T(послед) / T(паралл)")
|
||||
plt.title("График масштабируемости (Speedup)")
|
||||
plt.legend()
|
||||
plt.xlabel("Потоки")
|
||||
plt.ylabel("Ускорение S")
|
||||
plt.title("Масштабируемость")
|
||||
plt.grid(True)
|
||||
|
||||
plt.tight_layout()
|
||||
plt.savefig("out/performance_results.png")
|
||||
print("Графики сохранены в out/performance_results.png")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.makedirs("out", exist_ok=True)
|
||||
if not os.path.exists("out"):
|
||||
os.makedirs("out")
|
||||
build_benchmark()
|
||||
|
||||
+6
-6
@@ -12,14 +12,14 @@ except Exception:
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print("Использование: python exporter.py <logfile> [output_dir]")
|
||||
print("Использование: python exporter.py <logfile> <output_dir>")
|
||||
sys.exit(1)
|
||||
|
||||
logfile = sys.argv[1]
|
||||
out_dir = sys.argv[2] if len(sys.argv) >= 3 else "out"
|
||||
out_dir = sys.argv[2]
|
||||
os.makedirs(out_dir, exist_ok=True)
|
||||
|
||||
base_name = os.path.splitext(os.path.basename(logfile))[0]
|
||||
pics_dir = os.path.join(out_dir, "pics")
|
||||
os.makedirs(pics_dir, exist_ok=True)
|
||||
|
||||
pattern = re.compile(r"(START|END).*TID=(\d+).*range=\[(\d+),(\d+)\].*time=([\d.]+)")
|
||||
events = defaultdict(dict)
|
||||
@@ -66,7 +66,7 @@ for i, r in enumerate(rows):
|
||||
|
||||
plt.xlabel("Время (сек. от начала)")
|
||||
plt.ylabel("Задачи (рекурсивные вызовы)")
|
||||
plt.title(f"Временная диаграмма выполнения: {base_name}")
|
||||
plt.title(f"Временная диаграмма: {base_name}")
|
||||
plt.grid(True)
|
||||
plt.tight_layout()
|
||||
plt.savefig(os.path.join(pics_dir, f"{base_name}.png"))
|
||||
plt.savefig(os.path.join(out_dir, f"{base_name}.png"))
|
||||
|
||||
Reference in New Issue
Block a user