Обновить lec1/run_strong.py
This commit is contained in:
+8
-8
@@ -4,11 +4,11 @@ from mc import estimate_pi_serial
|
|||||||
from mc_parallel import estimate_pi_parallel
|
from mc_parallel import estimate_pi_parallel
|
||||||
N = 20_000_000
|
N = 20_000_000
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
t1, _, _ = bench(estimate_pi_serial, N)
|
t1, _, _ = bench(estimate_pi_serial, N)
|
||||||
print(f"Последовательно: T(1) = {t1:.2f} с")
|
print(f"Последовательно: T(1) = {t1:.2f} с")
|
||||||
print(" p T(p), с S(p) E(p)")
|
print(" p T(p), с S(p) E(p)")
|
||||||
for p in [1, 2, 4, 6, 8, 10]:
|
for p in [1, 2, 4, 6, 8, 10]:
|
||||||
with ProcessPoolExecutor(max_workers=p) as pool:
|
with ProcessPoolExecutor(max_workers=p) as pool:
|
||||||
tp, _, _ = bench(estimate_pi_parallel, N, pool, p)
|
tp, _, _ = bench(estimate_pi_parallel, N, pool, p)
|
||||||
s = t1 / tp
|
s = t1 / tp
|
||||||
print(f"{p:2d} {tp:8.2f} {s:5.2f} {s / p:5.2f}")
|
print(f"{p:2d} {tp:8.2f} {s:5.2f} {s / p:5.2f}")
|
||||||
|
|||||||
Reference in New Issue
Block a user