Created
October 23, 2018 05:59
-
-
Save RiseInRose/d4ddc230bff4e94ee9cf14cfa75f6adf to your computer and use it in GitHub Desktop.
这个主要测试python在各种环境下的效率问题。
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
| # author caturbhujadas_pc | |
| # date 2018/10/23 13:31 | |
| # wechat chending2012 | |
| from time import time | |
| from numba import autojit | |
| i = range(10000000) | |
| # @autojit() | |
| def do(each): | |
| # str(each) | |
| each += 1 | |
| # int(each) | |
| # each*each | |
| t1 = time() | |
| for each in i: | |
| do(each) | |
| print(time() - t1) | |
| t3 = time() | |
| [do(each) for each in i] | |
| print(time() - t3) | |
| t2 = time() | |
| map(do, i) | |
| print(time() - t2) | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
这个主要测试python各种内置方法的效率
测试结果:
2.5809388160705566
2.335479974746704
5.9604644775390625e-06
map的时间最短(电脑为4核)。