Files

14 lines
638 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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}")