Last active
November 4, 2019 19:43
-
-
Save nok-ko/955e9279a64e46c23de5ac8d14b59e58 to your computer and use it in GitHub Desktop.
This file contains 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
""" | |
Quickly time a function. | |
""" | |
import timeit | |
def quick_timeit(fname, case="", number=1000): | |
return timeit.timeit(stmt=f"{fname}({case})", setup=f"from __main__ import {fname}", number=number) | |
# usage: | |
## def some_fn(x,y): return x + y + min(x,y) | |
## def some_fn(*args): return sum(args) + min(args) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment