Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from multiprocessing import Pool
- import time
- import os
- def f(n):
- sum = 0
- for x in range(1000):
- sum+= x*x
- return sum
- if __name__ == '__main__':
- t1 = time.time()
- p = Pool()
- result = p.map(f, range(10))
- p.close()
- p.join()
- print('Pool Took : ' + time.time()-t1)
- t2 = time.time()
- result = []
- for x in range(10000):
- result.append(f(x))
- print('Serial Prcess : ' + time.time()-t2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement