Created
November 1, 2019 13:22
-
-
Save TopRoupi/811c70dcdbe01199048152036696cfb7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import multiprocessing | |
import time | |
nums = [5, 6, 7, 8, 9, 10] | |
def fatorial(n): | |
time.sleep(1) | |
r = 1 | |
for i in range(1, n+1): | |
r *= i | |
return r | |
################# | |
print(nums) | |
start = time.time() | |
result = tuple(map(fatorial,nums)) | |
end = time.time() | |
print(result) | |
print(start-end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import multiprocessing | |
import time | |
nums = [5, 6, 7, 8, 9, 10] | |
def fatorial(n): | |
time.sleep(1) | |
r = 1 | |
for i in range(1, n+1): | |
r *= i | |
return r | |
################# | |
print(nums) | |
start = time.time() | |
pool = multiprocessing.Pool() | |
result = pool.map(fatorial,nums) | |
end = time.time() | |
print(result) | |
print(start-end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment