Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to Profile a Python Program - Block 1
import cProfile
from math import sqrt
BIG_NUMBER = 10**25
def slow_function(n: int) -> None:
for _ in range(10**5):
sqrt(n)
def fast_function(n: int) -> None:
for _ in range(10**5):
n**.5
cProfile.run('slow_function(BIG_NUMBER)')
cProfile.run('fast_function(BIG_NUMBER)')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment