Skip to content

Instantly share code, notes, and snippets.

@akira093
Created September 16, 2014 07:23
Show Gist options
  • Select an option

  • Save akira093/bf9faf989bca1f7a2177 to your computer and use it in GitHub Desktop.

Select an option

Save akira093/bf9faf989bca1f7a2177 to your computer and use it in GitHub Desktop.
# coding:utf8
import multiprocessing
import time
"""
multiprocessing.Poolのchunkってどんな感じよー?
"""
def square(n):
return n**2
def timeit(n):
p = multiprocessing.Pool(2)
start = time.time()
p.map(square, range(100000), n)
print time.time()-start
if __name__ == '__main__':
timeit(1) # 1.43837404251
timeit(10) # 0.225604057312
timeit(100) # 0.095057964325
timeit(10000) # 0.0517990589142
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment