Teile 10 bis 12.
This commit is contained in:
14
teil12/pools.py
Normal file
14
teil12/pools.py
Normal file
@@ -0,0 +1,14 @@
|
||||
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")
|
||||
|
Reference in New Issue
Block a user