Добавить lec1/simple_run.py

This commit is contained in:
2026-10-17 08:39:41 +02:00
parent f334cee692
commit a9dc4afde6
+14
View File
@@ -0,0 +1,14 @@
from concurrent.futures import ProcessPoolExecutor
from bench import bench
from mc_parallel import estimate_pi_parallel
N_PER_WORKER = 5_000_000 # объём работы на одного исполнителя
if __name__ == "__main__":
print(" p N T(p), с E_weak")
for p in [1, 2, 4, 6, 8, 10]:
n = N_PER_WORKER * p # задача растёт вместе с числом процессов
with ProcessPoolExecutor(max_workers=p) as pool:
tp, _, _ = bench(estimate_pi_parallel, n, pool, p)
9
if p == 1:
t_base = tp
print(f"{p:2d} {n:10_d} {tp:7.2f} {t_base / tp:6.2f}")