Update parallel_calculations_with_python_using_Pool.py

This commit is contained in:
2025-08-15 16:21:34 +08:00
parent 62b8b4a11b
commit e58a4612ef

View File

@@ -15,9 +15,9 @@ def run_proc(name):
return name return name
if __name__ == '__main__': if __name__ == '__main__':
start_time = time.time() start_time = time.perf_counter()
with multiprocessing.Pool() as pool: with multiprocessing.Pool() as pool:
results = pool.map(run_proc, [f"task {i}" for i in range(64)]) results = pool.map(run_proc, [f"task {i}" for i in range(64)])
end_time = time.time() end_time = time.perf_counter()
print(results) print(results)
print(end_time - start_time) print(end_time - start_time)