You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
299 B
14 lines
299 B
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")
|
|
|
|
|