Created
December 29, 2018 07:26
-
-
Save SteadBytes/fe3e7a7e1029bb79381e29563e83857a to your computer and use it in GitHub Desktop.
Time python function
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
from functools import partial | |
import timeit | |
def measure_time(n, f, *args, **kwargs): | |
""" | |
Args: | |
n (int): number of tests | |
f (func): function to time | |
*args: any arguments to pass to f | |
""" | |
return timeit.timeit(partial(f, *args, **kwargs), number=n) | |
# measure_time(100, my_func, input_to_my_func, a_kwarg_to_my_func=1) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment