Created
September 16, 2014 07:23
-
-
Save akira093/bf9faf989bca1f7a2177 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # 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