add lec1,lec2,lec3,lec4

This commit is contained in:
2026-11-14 10:09:26 +03:00
commit a64a74f1d5
23 changed files with 398 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
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)
if p == 1:
t_base = tp
print(f"{p:2d} {n:10_d} {tp:7.2f} {t_base / tp:6.2f}")