15 lines
299 B
Python
15 lines
299 B
Python
from multiprocessing import Pool
|
|
import time
|
|
|
|
def calculate_square(n):
|
|
return n*n
|
|
|
|
if __name__ == "__main__":
|
|
starttime = time.time()
|
|
pool = Pool()
|
|
pool.map(calculate_square, range(0, 5))
|
|
pool.close()
|
|
endtime = time.time()
|
|
print(f"Time taken {endtime-starttime} seconds")
|
|
|