Skip to content

Instantly share code, notes, and snippets.

@luabida
Last active November 29, 2022 14:19
Show Gist options
  • Save luabida/3530e6fa15839f4a8a855e152e960db0 to your computer and use it in GitHub Desktop.
Save luabida/3530e6fa15839f4a8a855e152e960db0 to your computer and use it in GitHub Desktop.
Profiling using `timeit.repeat()`, with Min, Mean and Max
from timeit import repeat
from statistics import mean
def stats(stmt, r=100):
res = repeat(stmt, globals=globals(), repeat=r)
print(f'Avg: {mean(res)}\nMin: {min(res)}\nMax: {max(res)}')
"""
def foo():
return 1+1
stats('foo()')
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment