Created
April 13, 2016 15:30
-
-
Save mcleary/e4ff32a01d9ef915941e0aa022e2d7b1 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
from multiprocessing import Pool | |
import math | |
import time | |
def func(param): | |
print 'Iniciando funcao para param=' + str(param) | |
k = 0.0 | |
for i in range(0, 1000000*param): | |
k += math.sin(i) * math.sqrt(i) * math.pow(i, 20) | |
return k | |
if __name__ == '__main__': | |
pool = Pool(4) | |
t0 = time.time() | |
print pool.map(func, [i for i in range(0, 5)]) | |
print time.time() - t0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment