-
-
Save corona10/bb782b1d85a501747d2738d724cb9dd1 to your computer and use it in GitHub Desktop.
CPython 3.11 recursive benchmark
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
import pyperf | |
runner = pyperf.Runner() | |
runner.timeit(name="bench fib", | |
stmt=""" | |
_ = fib(10) | |
""", | |
setup = """ | |
def fib(n): | |
if n == 0: | |
return 0 | |
if n == 1 or n == 2: | |
return 1 | |
return fib(n-1) + fib(n-2) | |
""" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mean +- std dev: [3_10] 9.24 us +- 0.13 us -> [3_11] 5.21 us +- 0.01 us: 1.77x faster