Skip to content

Instantly share code, notes, and snippets.

@bilalozdemir
Last active April 5, 2021 11:27
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save bilalozdemir/c75ac77db927d7593376d98e5589a83e to your computer and use it in GitHub Desktop.
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