Skip to content

Instantly share code, notes, and snippets.

@corona10
Created March 8, 2022 03:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corona10/bb782b1d85a501747d2738d724cb9dd1 to your computer and use it in GitHub Desktop.
Save corona10/bb782b1d85a501747d2738d724cb9dd1 to your computer and use it in GitHub Desktop.
CPython 3.11 recursive benchmark
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)
"""
)
@corona10
Copy link
Author

corona10 commented Mar 8, 2022

Mean +- std dev: [3_10] 9.24 us +- 0.13 us -> [3_11] 5.21 us +- 0.01 us: 1.77x faster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment