Last active
November 29, 2022 14:19
-
-
Save luabida/3530e6fa15839f4a8a855e152e960db0 to your computer and use it in GitHub Desktop.
Profiling using `timeit.repeat()`, with Min, Mean and Max
This file contains hidden or 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
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