Created
April 28, 2014 19:52
-
-
Save unionx/11382264 to your computer and use it in GitHub Desktop.
对比一下CPython和PyPy的速度
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
#!/usr/bin/env python | |
import cProfile | |
def main(): | |
for i in range(100000000): | |
i / 5.53892138021312312 * 23.23123121321321312 | |
print(i) | |
cProfile.run("main()") | |
''' | |
% python --version | |
Python 2.7.5 | |
% python ask.py | |
99999999 | |
4 function calls in 12.158 seconds | |
Ordered by: standard name | |
ncalls tottime percall cumtime percall filename:lineno(function) | |
1 0.000 0.000 12.158 12.158 <string>:1(<module>) | |
1 10.191 10.191 12.158 12.158 ask.py:4(main) | |
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} | |
1 1.967 1.967 1.967 1.967 {range} | |
% pypy --version | |
Python 2.7.3 (87aa9de10f9c, Nov 24 2013, 20:57:21) | |
[PyPy 2.2.1 with GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] | |
% pypy ask.py | |
99999999 | |
4 function calls in 0.122 seconds | |
Ordered by: standard name | |
ncalls tottime percall cumtime percall filename:lineno(function) | |
1 0.000 0.000 0.122 0.122 <string>:1(<module>) | |
1 0.122 0.122 0.122 0.122 ask.py:4(main) | |
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} | |
1 0.000 0.000 0.000 0.000 {range} | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
来个fibs看看!